added: some tests for Big<> and Parser<> classes (tests2 directory)
git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@1225 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
+1
-1
@@ -43,5 +43,5 @@ clean:
|
|||||||
rm -f big
|
rm -f big
|
||||||
rm -f big2
|
rm -f big2
|
||||||
rm -f parser
|
rm -f parser
|
||||||
# on MS Windows can automatically be added suffixes .exe to the names of output programs
|
# on MS Windows suffixes .exe will be automatically added
|
||||||
rm -f *.exe
|
rm -f *.exe
|
||||||
|
|||||||
+128
@@ -0,0 +1,128 @@
|
|||||||
|
#CC = g++
|
||||||
|
CC = clang++
|
||||||
|
CFLAGS = -Wall -pedantic -O2 -I..
|
||||||
|
|
||||||
|
|
||||||
|
.SUFFIXES: .cpp .o
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: big_64_64 big_64_128 big_64_192 big_64_256 big_64_512 big_64_1024 big_64_2048 big_64_4096 big_128_512 big_256_1024 big_512_2048 big_128_4096
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
big_64_64: main.cpp
|
||||||
|
$(CC) -o big_64_64 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=64 main.cpp
|
||||||
|
|
||||||
|
big_64_128: main.cpp
|
||||||
|
$(CC) -o big_64_128 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=128 main.cpp
|
||||||
|
|
||||||
|
big_64_192: main.cpp
|
||||||
|
$(CC) -o big_64_192 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=192 main.cpp
|
||||||
|
|
||||||
|
big_64_256: main.cpp
|
||||||
|
$(CC) -o big_64_256 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=256 main.cpp
|
||||||
|
|
||||||
|
big_64_512: main.cpp
|
||||||
|
$(CC) -o big_64_512 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=512 main.cpp
|
||||||
|
|
||||||
|
big_64_1024: main.cpp
|
||||||
|
$(CC) -o big_64_1024 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=1024 main.cpp
|
||||||
|
|
||||||
|
big_64_2048: main.cpp
|
||||||
|
$(CC) -o big_64_2048 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=2048 main.cpp
|
||||||
|
|
||||||
|
big_64_4096: main.cpp
|
||||||
|
$(CC) -o big_64_4096 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=64 -DTTMATH_TEST_BIG_MANTISSA=4096 main.cpp
|
||||||
|
|
||||||
|
big_128_512: main.cpp
|
||||||
|
$(CC) -o big_128_512 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=128 -DTTMATH_TEST_BIG_MANTISSA=512 main.cpp
|
||||||
|
|
||||||
|
big_256_1024: main.cpp
|
||||||
|
$(CC) -o big_256_1024 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=256 -DTTMATH_TEST_BIG_MANTISSA=1024 main.cpp
|
||||||
|
|
||||||
|
big_512_2048: main.cpp
|
||||||
|
$(CC) -o big_512_2048 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=512 -DTTMATH_TEST_BIG_MANTISSA=2048 main.cpp
|
||||||
|
|
||||||
|
big_128_4096: main.cpp
|
||||||
|
$(CC) -o big_128_4096 -s $(CFLAGS) -DTTMATH_TEST_BIG_EXPONENT=128 -DTTMATH_TEST_BIG_MANTISSA=4096 main.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
test: all
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=64"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_64 "foo" | tee big_64_64.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=128"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_128 "foo" | tee big_64_128.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=192"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_192 "foo" | tee big_64_192.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=256"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_256 "foo" | tee big_64_256.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=512"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_512 "foo" | tee big_64_512.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=1024"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_1024 "foo" | tee big_64_1024.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=2048"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_2048 "foo" | tee big_64_2048.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=64 and mantissa=4096"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_64_4096 "foo" | tee big_64_4096.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=128 and mantissa=512"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_128_512 "foo" | tee big_128_512.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=128 and mantissa=4096"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_128_4096 "foo" | tee big_128_4096.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=256 and mantissa=1024"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_256_1024 "foo" | tee big_256_1024.out
|
||||||
|
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
@echo "making tests for exponent=512 and mantissa=2048"
|
||||||
|
@echo "****************************************************************************"
|
||||||
|
cat tests.txt | xargs -S 4096 -I foo ./big_512_2048 "foo" | tee big_512_2048.out
|
||||||
|
|
||||||
|
./check_files.sh
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.out
|
||||||
|
rm -f big_64_64 big_64_128 big_64_192 big_64_256 big_64_512 big_64_1024 big_64_2048 big_64_4096 big_128_512 big_256_1024 big_512_2048 big_128_4096
|
||||||
|
# on MS Windows suffixes .exe will be automatically added
|
||||||
|
rm -f *.exe
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
was_error=0
|
||||||
|
|
||||||
|
for expected in *.expected ; do
|
||||||
|
|
||||||
|
out=`basename $expected .expected`.out
|
||||||
|
|
||||||
|
if [ -f $out ] ; then
|
||||||
|
diff -u $out $expected
|
||||||
|
|
||||||
|
if [ `diff -u $out $expected | wc -l` -ne 0 ] ; then
|
||||||
|
was_error=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "there is no file: $out"
|
||||||
|
was_error=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [ $was_error -eq 0 ] ; then
|
||||||
|
echo "****************************************************************************"
|
||||||
|
echo " congratulations: all tests passed successfully"
|
||||||
|
echo "****************************************************************************"
|
||||||
|
else
|
||||||
|
echo "****************************************************************************"
|
||||||
|
echo " error: not all tests passed successfully"
|
||||||
|
echo "****************************************************************************"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#include <ttmath/ttmath.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char ** argv)
|
||||||
|
{
|
||||||
|
typedef ttmath::Big<TTMATH_BITS(TTMATH_TEST_BIG_EXPONENT), TTMATH_BITS(TTMATH_TEST_BIG_MANTISSA)> MyBig;
|
||||||
|
ttmath::Parser<MyBig> parser;
|
||||||
|
std::string all_input;
|
||||||
|
|
||||||
|
for(int i=1 ; i<argc ; ++i)
|
||||||
|
{
|
||||||
|
if( i > 1 )
|
||||||
|
all_input += ' ';
|
||||||
|
|
||||||
|
all_input += argv[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << all_input << " = ";
|
||||||
|
ttmath::ErrorCode err = parser.Parse(all_input);
|
||||||
|
|
||||||
|
if( err == ttmath::err_ok )
|
||||||
|
{
|
||||||
|
for(size_t i=0 ; i < parser.stack.size() ; ++i)
|
||||||
|
{
|
||||||
|
if( i > 0 )
|
||||||
|
std::cout << " ; ";
|
||||||
|
|
||||||
|
std::cout << parser.stack[i].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "error: " << static_cast<int>(err) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+2161
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user