Exemple #1
0
int main()
{
  testFloat();
  testDouble();

  return 0;
}
Exemple #2
0
int main(int argc, char *argv[]) {
    std::cout << "ExpressionParser example" << std::endl;

    //testAST1();
    //testFunction();
    //testPerformance();
    //testPerformance2();
    testFloat();

    return 0;
}
Exemple #3
0
int main(int argc, char *argv[]) {

    decContextTestEndian(0);    // warn if DECLITEND is wrong

    testFloat();
    testDouble();
    testDecDouble();
    testDecQuad();

    return 0;
}
    void test() {
        std::cout << "Testing float vs double ..." << std::endl;
        
        auto d = 0.0;
        auto time0 = getTime();
        d += testDouble(d);
        auto time1 = getTime();
        std::cout << '\t' << "Double " << diffclock(time1, time0) << std::endl;

        auto f = 0.0f;
        auto time2 = getTime();
        f += testFloat(d);
        auto time3 = getTime();
        
        std::cout << '\t' << "Float " << diffclock(time3, time2) << std::endl;
        std::cout << "\n **** \n\n";
    }
Exemple #5
0
 void test() {
     std::cout << "Testing float vs double ..." << std::endl;
     
     auto d = 0.0;
     
     auto test0 = [&] {
         d += testDouble(d);
     };
     
     auto f = 0.0f;
     auto test1 = [&] {
         f += testFloat(d);
     };
     
     ADD_BENCHMARK("FloatVSDouble \t Double", test0);
     ADD_BENCHMARK("FloatVSDouble \t Float", test1);
     
     benchpress::run_benchmarks(benchpress::options());
     
 }
Exemple #6
0
int
main()
{
    initLexer(0);

    testTokenStream("1 + 1", tokens0, N_ELEM(tokens0));
    testTokenStream("{a comment line} $1 + 1", tokens0, N_ELEM(tokens0));
    testTokenStream("{{a nested comment}} $1 + 1", tokens0, N_ELEM(tokens0));
    testTokenStream("{{{a nested doc comment}} $1 + 1", tokens0, N_ELEM(tokens0));
    testTokenStream("x-1+y", tokens1, N_ELEM(tokens1));
    testTokenStream("_x0{some comment 1} - 1 + y_99", tokens1, N_ELEM(tokens1));
    testTokenStream("con CON con99 Con 99", tokens2, N_ELEM(tokens2));
    testTokenStream("< =< => > == = +<", tokens3, N_ELEM(tokens3));
    testTokenStream(token4test, tokens4, N_ELEM(tokens4));
    testTokenStream(token5test, tokens5, N_ELEM(tokens5));
    testTokenStream(token6test, tokens6, N_ELEM(tokens6));
    testTokenStream(token7test, tokens7, N_ELEM(tokens7));

    testNumber("0", 0);
    testNumber("00", 0);
    testNumber("007", 7);
    testNumber("008", 8);
    testNumber("\t \t 123", 123);
    testNumber("65535", 65535);
    testNumber("  $41", 65);
    testNumber("$01_ff", 511);
    testNumber("$A5", 165);
    testNumber("%101", 5);
    testNumber("%11", 3);
    testNumber("%%31", 13);
    testNumber("80_000_000", 80000000);

    testFloat("1.0", 1.0f);
    testFloat("2.0", 2.0f);
    testFloat("0.01", 0.01f);
    testFloat("1.0e-2", 0.01f);
    testFloat("1.e-2", 0.01f);
    testFloat("3.14e5", 314000.0f);

    testIdentifier("x99+8", "X99");
    testIdentifier("_a_b", "_A_b");
    printf("all tests passed\n");
    return 0;
}
Exemple #7
0
TEST(NumericLexTest, Float) {
	testFloat("1.0", 1.0);
	testFloat("1.1", 1.1);
	testFloat("1.2", 1.2);
	testFloat("1.3", 1.3);
	testFloat("1.4", 1.4);
	testFloat("1.5", 1.5);
	testFloat("1.6", 1.6);
	testFloat("1.7", 1.7);
	testFloat("1.8", 1.8);
	testFloat("1.9", 1.9);
	testFloat("123.2", 123.2);
}
Exemple #8
0
TEST(NumericLexTest, FloatEmptyFractionalPart) {
	testFloat("0.", 0.0);
	testFloat("1.", 1.0);
	testFloat("2.", 2.0);
	testFloat("3.", 3.0);
	testFloat("4.", 4.0);
	testFloat("5.", 5.0);
	testFloat("6.", 6.0);
	testFloat("7.", 7.0);
	testFloat("8.", 8.0);
	testFloat("9.", 9.0);
	testFloat("10.", 10.0);
	testFloat("20.", 20.0);
}
Exemple #9
0
TEST(NumericLexTest, DISABLED_FloatEmptyIntegerPart) {
	testFloat(".0", 0.0);
	testFloat(".1", 0.1);
	testFloat(".2", 0.2);
	testFloat(".3", 0.3);
	testFloat(".4", 0.4);
	testFloat(".5", 0.5);
	testFloat(".6", 0.6);
	testFloat(".7", 0.7);
	testFloat(".8", 0.8);
	testFloat(".9", 0.9);
	testFloat(".123", 0.123);
}
bool ftoaUnitTest()
{
	std::cout << "ftoaUnitTest()" << std::endl;
	std::cout << std::endl;

	testFloat(std::numeric_limits<float>::infinity(),"INF");
	testFloat(-std::numeric_limits<float>::infinity(),"-INF");
	testFloat(std::numeric_limits<float>::quiet_NaN(),"NaN");
	testFloat(0,                 "0");
	testFloat(1,                 "1");
	testFloat(1.0,               "1");
	testFloat(1.00001f,           "1.00001");
	testFloat(1.00001e7f,         "1.00001e7");
	testFloat(1.234567f,          "1.234567");
	testFloat(123456,            "123456");
	testFloat(1234567,           "1.23457e6");
	testFloat(1234567e23f,        "1.23457e29");
	testFloat(1234567e-23f,       "1.23457e-17");
	testFloat(123456.789f,        "123456.8");

	std::cout << std::endl;
	std::cout << std::endl;

	testFloat(-1,                 "-1");
	testFloat(-1.0,               "-1");
	testFloat(-1.00001f,           "-1.00001");
	testFloat(-1.00001e7f,         "-1.00001e7");
	testFloat(-123456,            "-123456");
	testFloat(-1234567,           "-1.23457e6");
	testFloat(-1234567e23f,        "-1.23457e29");
	testFloat(-1234567e-23f,       "-1.23457e-17");
	testFloat(-123456.789f,        "-123456.8");

	std::cout << std::endl;
	std::cout << std::endl;

	testFloat(999999,             "999999");
	testFloat(999999.9f,           "1e6");
	testFloat(0.0001f,             "10e-5");
	testFloat(0.00010006f,         "1.0006e-4");
	testFloat(0.000098f,           "9.8e-5");

	std::cout << std::endl;
	std::cout << std::endl;

	testFloat(-999999,            "-999999");
	testFloat(-999999.9f,          "-1e6");
	testFloat(-0.0001f,            "-10e-5");
	testFloat(-0.000098f,          "-9.8e-5");

	std::cout << std::endl;
	std::cout << std::endl;

	testFloat(0.00001f,             "10e-6");
	testFloat(0.0001f,              "10e-5");
	testFloat(0.001f,               "0.000999987");
	testFloat(0.01f,                "0.00999999");
	testFloat(0.1f,                 "0.1");
	testFloat(1,                   "1");
	testFloat(1,                   "1");
	testFloat(10,                  "10");
	testFloat(100,                 "100");
	testFloat(1000,                "1000");
	testFloat(10000,               "10000");
	testFloat(100000,              "100000");
	testFloat(1000000,             "1e6");

	std::cout << std::endl;
	std::cout << std::endl;

	return errroCount == 0;
}