// Create our own test to check the different function of our class // This function will take two arguments: // * The test case name // * The test name TEST(DummyBuild, NoInitialisation) { cv::Mat test_image=cv::imread("../src/tests/unit/common/imagetest.bmp"); GTEST_ASSERT_EQ(test_image.cols,640); GTEST_ASSERT_EQ(test_image.rows,480); }
TEST(OpenParentesisTest, Test_DFA_002) { DFAOpenParentesis id; GTEST_ASSERT_EQ(Token::OpenParentesis, id.TokenType("(")); id.reset(); bool b = id.walk('('); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); }
TEST(MinusTest, Test_DFA_002) { DFAMinus id; GTEST_ASSERT_EQ(Token::Minus, id.TokenType("-")); id.reset(); bool b = id.walk('-'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); }
TEST(GreaterTest, Test_DFA_002) { DFAGreater id; GTEST_ASSERT_EQ(Token::Greater, id.TokenType(">")); id.reset(); bool b = id.walk('>'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); }
TEST(LogicalAndOrTest, Test_DFA_001) { DFALogicalOr id; std::string s ="||"; id.reset(); for(std::string::const_iterator it = s.begin(); it != s.end(); ++it) { bool b = id.walk(*it); GTEST_ASSERT_EQ(true, b); } GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(Token::LogicalOr, id.TokenType("||")); }
TEST(OpenParentesisTest, Test_DFA_001) { DFAOpenParentesis id; std::string s = "("; id.reset(); for(std::string::const_iterator it = s.begin(); it != s.end(); ++it) { bool b = id.walk(*it); GTEST_ASSERT_EQ(true, b); } GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(Token::OpenParentesis, id.TokenType("(")); }
TEST(MinusTest, Test_DFA_001) { DFAMinus id; std::string s = "-"; id.reset(); for(std::string::const_iterator it = s.begin(); it != s.end(); ++it) { bool b = id.walk(*it); GTEST_ASSERT_EQ(true, b); } GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(Token::Minus, id.TokenType("-")); }
TEST(LessEqualTest, Test_DFA_001) { DFALessEqual id; std::string s ="<="; id.reset(); for(std::string::const_iterator it = s.begin(); it != s.end(); ++it) { bool b = id.walk(*it); GTEST_ASSERT_EQ(true, b); } GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(Token::LessEqual, id.TokenType("<=")); }
TEST(BisonFlexTest, Test0009) { FileHolder holder("./Resources/Example0009.titan"); GTEST_ASSERT_NE((void*)0, holder.f); BufferStateHolder bp(yy_create_buffer(holder.f, YY_BUF_SIZE)); yy_switch_to_buffer(bp.bp); int ans = yyparse(); yy_flush_buffer(bp.bp); GTEST_ASSERT_EQ(0, ans); }
TEST(LogicalAndOrTest, Test_DFA_002) { DFALogicalOr id; GTEST_ASSERT_EQ(Token::LogicalOr, id.TokenType("||")); id.reset(); bool b = id.walk('|'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(false, id.isTerminal()); b = id.walk('|'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); }
TEST(LessEqualTest, Test_DFA_002) { DFALessEqual id; GTEST_ASSERT_EQ(Token::LessEqual, id.TokenType("<=")); id.reset(); bool b = id.walk('<'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(false, id.isTerminal()); b = id.walk('='); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); }
TEST(SHRTest, Test_DFA_002) { DFASHR id; id.reset(); bool b = id.walk('>'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(false, id.isTerminal()); b = id.walk('>'); GTEST_ASSERT_EQ(true, b); GTEST_ASSERT_EQ(true, id.isValid()); GTEST_ASSERT_EQ(true, id.isTerminal()); GTEST_ASSERT_EQ(Token::SHR, id.TokenType(">>")); }
/** * Calculates the value of a triangle number by dividing the additions up into tasks * * A triangle number is defined as: * Tn = 1 + 2 + 3 + ... + n * * The code is checked against the numerical solution which is: * Tn = n * (n + 1) / 2 * * TODO: Use gtest's 'Value Parameterized Tests' to test multiple triangle numbers */ void TriangleNumberMainTask(ftl::TaskScheduler *taskScheduler, void * /*arg*/) { // Define the constants to test const uint64 triangleNum = 47593243ULL; const uint64 numAdditionsPerTask = 10000ULL; const uint64 numTasks = (triangleNum + numAdditionsPerTask - 1ULL) / numAdditionsPerTask; // Create the tasks auto *tasks = new ftl::Task[numTasks]; // We have to declare this on the heap so other threads can access it auto *subsets = new NumberSubset[numTasks]; uint64 nextNumber = 1ULL; for (uint64 i = 0ULL; i < numTasks; ++i) { NumberSubset *subset = &subsets[i]; subset->Start = nextNumber; subset->End = nextNumber + numAdditionsPerTask - 1ULL; if (subset->End > triangleNum) { subset->End = triangleNum; } tasks[i] = {AddNumberSubset, subset}; nextNumber = subset->End + 1; } // Schedule the tasks and wait for them to complete ftl::AtomicCounter counter(taskScheduler); taskScheduler->AddTasks(numTasks, tasks, &counter); delete[] tasks; taskScheduler->WaitForCounter(&counter, 0); // Add the results uint64 result = 0ULL; for (uint64 i = 0; i < numTasks; ++i) { result += subsets[i].Total; } // Test GTEST_ASSERT_EQ(triangleNum * (triangleNum + 1ULL) / 2ULL, result); // Cleanup delete[] subsets; }
TEST(Libev, Webscoket) { ServerWebHandler hand(kHinf); common::libev::tcp::TcpServer* serv = new common::libev::tcp::TcpServer(g_hs, false, &hand); common::ErrnoError err = serv->Bind(true); ASSERT_FALSE(err); err = serv->Listen(5); ASSERT_FALSE(err); auto tp = THREAD_MANAGER()->CreateThread(&ExitWebServer, serv); GTEST_ASSERT_EQ(tp->GetHandle(), common::threads::invalid_thread_handle()); bool res_start = tp->Start(); ASSERT_TRUE(res_start); int res_exec = serv->Exec(); ASSERT_TRUE(res_exec == EXIT_SUCCESS); tp->Join(); delete serv; }