6 #ifndef JSONTEST_H_INCLUDED 7 # define JSONTEST_H_INCLUDED 10 # include <json/value.h> 11 # include <json/writer.h> 50 typedef unsigned int Id;
79 const char *expr = 0 );
88 void printFailure(
bool printTestName )
const;
93 std::ostringstream oss;
95 oss.setf( std::ios_base::floatfield );
97 return addToLastFailure(oss.str());
108 unsigned int getAssertionNestingLevel()
const;
110 void addFailureInfo(
const char *
file,
unsigned int line,
111 const char *expr,
unsigned int nestingLevel );
115 typedef std::deque<Failure> Failures;
134 virtual const char *
testName()
const = 0;
140 virtual void runTestCase() = 0;
158 int runCommandLine(
int argc,
const char *
argv[] )
const;
161 bool runAllTest(
bool printSummary )
const;
164 unsigned int testCount()
const;
172 static void printUsage(
const char *appName );
179 void listTests()
const;
181 static void preventDialogOnCrash();
184 typedef std::deque<TestCaseFactory> Factories;
188 template<
typename T,
typename U>
191 const char *
file,
unsigned int line,
const char *expr )
193 if ( expected != actual )
196 result <<
"Expected: " << expected <<
"\n";
197 result <<
"Actual : " << actual;
206 const char *
file,
unsigned int line,
const char *expr );
214 #define JSONTEST_ASSERT( expr ) \ 219 result_->addFailure( __FILE__, __LINE__, #expr ) 223 #define JSONTEST_ASSERT_PRED( expr ) \ 225 JsonTest::PredicateContext _minitest_Context = { \ 226 result_->predicateId_, __FILE__, __LINE__, #expr }; \ 227 result_->predicateStackTail_->next_ = &_minitest_Context; \ 228 result_->predicateId_ += 1; \ 229 result_->predicateStackTail_ = &_minitest_Context; \ 231 result_->popPredicateContext(); \ 236 #define JSONTEST_ASSERT_EQUAL( expected, actual ) \ 237 JsonTest::checkEqual( *result_, expected, actual, \ 238 __FILE__, __LINE__, \ 239 #expected " == " #actual ) 242 #define JSONTEST_ASSERT_STRING_EQUAL( expected, actual ) \ 243 JsonTest::checkStringEqual( *result_, \ 244 std::string(expected), std::string(actual), \ 245 __FILE__, __LINE__, \ 246 #expected " == " #actual ) 249 #define JSONTEST_FIXTURE( FixtureType, name ) \ 250 class Test##FixtureType##name : public FixtureType \ 253 static JsonTest::TestCase *factory() \ 255 return new Test##FixtureType##name(); \ 258 virtual const char *testName() const \ 260 return #FixtureType "/" #name; \ 262 virtual void runTestCase(); \ 265 void Test##FixtureType##name::runTestCase() 267 #define JSONTEST_FIXTURE_FACTORY( FixtureType, name ) \ 268 &Test##FixtureType##name::factory 270 #define JSONTEST_REGISTER_FIXTURE( runner, FixtureType, name ) \ 271 (runner).add( JSONTEST_FIXTURE_FACTORY( FixtureType, name ) ) 273 #endif // ifndef JSONTEST_H_INCLUDED line
Definition: buildtests.py:37
const char * expr_
Definition: jsontest.h:54
Definition: XMLHttpRequest.idl:39
Definition: jsontest.h:34
unsigned int line_
Definition: jsontest.h:53
Unit testing framework.
Definition: jsontest.cpp:71
double U(int64_t x, double alpha)
Definition: metric_recorder.cc:414
TestResult & checkStringEqual(TestResult &result, const std::string &expected, const std::string &actual, const char *file, unsigned int line, const char *expr)
Definition: jsontest.cpp:561
const char * file_
Definition: jsontest.h:52
unsigned int line_
Definition: jsontest.h:38
std::string expr_
Definition: jsontest.h:39
TestCase *(* TestCaseFactory)()
Function pointer type for TestCase factory.
Definition: jsontest.h:144
PredicateContext::Id predicateId_
Definition: jsontest.h:70
PredicateContext * next_
Definition: jsontest.h:55
VoEFile * file
Definition: voe_cmd_test.cc:59
Definition: jsontest.h:61
const char * file_
Definition: jsontest.h:37
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
rtc::scoped_refptr< PeerConnectionFactoryInterface > factory(webrtc::CreatePeerConnectionFactory(network_thread.get(), worker_thread.get(), signaling_thread.get(), nullptr, encoder_factory, decoder_factory))
Definition: peerconnection_jni.cc:1838
GLuint index
Definition: gl2.h:383
Failure * failure_
Definition: jsontest.h:58
EGLAttrib * value
Definition: eglext.h:120
PredicateContext * predicateStackTail_
Definition: jsontest.h:73
EGLImageKHR EGLint * name
Definition: eglext.h:851
const char * argv[]
Definition: DumpRenderTree.cpp:1631
unsigned int Id
Definition: jsontest.h:50
std::string message_
Definition: jsontest.h:40
string expected
Definition: buildtests.py:33
unsigned long long int UInt64
Definition: config.h:89
GLsizei const GLchar *const * string
Definition: gl2.h:479
result
Definition: target-blank-opener-post-window.php:5
long long int Int64
Definition: config.h:88
void run(Test f, element_t *first, element_t *last, int number_of_times)
Definition: container.cpp:101
unsigned int nestingLevel_
Definition: jsontest.h:41
TestResult * result_
Definition: jsontest.h:137
Definition: jsontest.h:125
Definition: jsontest.h:146
TestCase
Definition: gtest_test_utils.py:62
TestResult & addFailure(const char *file, unsigned int line, const char *expr=0)
Adds an assertion failure.
Definition: jsontest.cpp:96
Definition: jsontest.h:48
std::ostream & operator<<(std::ostream &os, const SdpAudioFormat &saf)
Definition: audio_format.cc:66
GLuint GLsizei const GLchar * message
Definition: gl2ext.h:137
int failed
Definition: testapi.c:58
Id id_
Definition: jsontest.h:51
testName
Definition: plotTimingTest.m:13
TestResult & checkEqual(TestResult &result, const T &expected, const U &actual, const char *file, unsigned int line, const char *expr)
Definition: jsontest.h:190