mirror of
				https://github.com/eledio-devices/thirdparty-tinyexpr.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Added additional tests.
This commit is contained in:
		
							
								
								
									
										8
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								Makefile
									
									
									
									
									
								
							| @@ -2,13 +2,16 @@ CCFLAGS = -ansi -Wall -Wshadow -O2 | |||||||
| LFLAGS = -lm | LFLAGS = -lm | ||||||
|  |  | ||||||
|  |  | ||||||
| all: test bench example example2 example3 | all: test test_pr bench example example2 example3 | ||||||
|  |  | ||||||
|  |  | ||||||
| test: test.o tinyexpr.o | test: test.c tinyexpr.c | ||||||
| 	$(CC) $(CCFLAGS) -o $@ $^ $(LFLAGS) | 	$(CC) $(CCFLAGS) -o $@ $^ $(LFLAGS) | ||||||
| 	./$@ | 	./$@ | ||||||
|  |  | ||||||
|  | test_pr: test.c tinyexpr.c | ||||||
|  | 	$(CC) $(CCFLAGS) -DTE_POW_FROM_RIGHT -DTE_NAT_LOG -o $@ $^ $(LFLAGS) | ||||||
|  | 	./$@ | ||||||
|  |  | ||||||
| bench: benchmark.o tinyexpr.o | bench: benchmark.o tinyexpr.o | ||||||
| 	$(CC) $(CCFLAGS) -o $@ $^ $(LFLAGS) | 	$(CC) $(CCFLAGS) -o $@ $^ $(LFLAGS) | ||||||
| @@ -25,7 +28,6 @@ example3: example3.o tinyexpr.o | |||||||
| .c.o: | .c.o: | ||||||
| 	$(CC) -c $(CCFLAGS) $< -o $@ | 	$(CC) -c $(CCFLAGS) $< -o $@ | ||||||
|  |  | ||||||
|  |  | ||||||
| clean: | clean: | ||||||
| 	rm *.o | 	rm *.o | ||||||
| 	rm *.exe | 	rm *.exe | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								test.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								test.c
									
									
									
									
									
								
							| @@ -90,15 +90,24 @@ void test_results() { | |||||||
|         {"asin sin (-0.5)", -0.5}, |         {"asin sin (-0.5)", -0.5}, | ||||||
|         {"(asin sin (-0.5))", -0.5}, |         {"(asin sin (-0.5))", -0.5}, | ||||||
|  |  | ||||||
|         {"log 1000", 3}, |         {"log10 1000", 3}, | ||||||
|         {"log 1e3", 3}, |         {"log10 1e3", 3}, | ||||||
|         {"log 1000", 3}, |         {"log10 1000", 3}, | ||||||
|         {"log 1e3", 3}, |         {"log10 1e3", 3}, | ||||||
|         {"log(1000)", 3}, |         {"log10(1000)", 3}, | ||||||
|         {"log(1e3)", 3}, |         {"log10(1e3)", 3}, | ||||||
|         {"log 1.0e3", 3}, |         {"log10 1.0e3", 3}, | ||||||
|         {"10^5*5e-5", 5}, |         {"10^5*5e-5", 5}, | ||||||
|  |  | ||||||
|  | #ifdef TE_NAT_LOG | ||||||
|  |         {"log 1000", 6.9078}, | ||||||
|  |         {"log e", 1}, | ||||||
|  |         {"log (e^10)", 10}, | ||||||
|  | #else | ||||||
|  |         {"log 1000", 3}, | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |         {"ln (e^10)", 10}, | ||||||
|         {"100^.5+1", 11}, |         {"100^.5+1", 11}, | ||||||
|         {"100 ^.5+1", 11}, |         {"100 ^.5+1", 11}, | ||||||
|         {"100^+.5+1", 11}, |         {"100^+.5+1", 11}, | ||||||
| @@ -320,7 +329,7 @@ void test_functions() { | |||||||
|         cross_check("exp x", exp(x)); |         cross_check("exp x", exp(x)); | ||||||
|         cross_check("floor x", floor(x)); |         cross_check("floor x", floor(x)); | ||||||
|         cross_check("ln x", log(x)); |         cross_check("ln x", log(x)); | ||||||
|         cross_check("log x", log10(x)); |         cross_check("log10 x", log10(x)); | ||||||
|         cross_check("sin x", sin(x)); |         cross_check("sin x", sin(x)); | ||||||
|         cross_check("sinh x", sinh(x)); |         cross_check("sinh x", sinh(x)); | ||||||
|         cross_check("sqrt x", sqrt(x)); |         cross_check("sqrt x", sqrt(x)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user