User Tools

Site Tools


gtest

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gtest [2011/01/20 14:21] – Page name changed from android_gtest to gtest suapapagtest [2013/08/03 05:04] (current) – external edit 127.0.0.1
Line 1: Line 1:
 안드로이드에서 cpp를 테스트하기 위한 testsuite. gtest를 안드로이드 용으로 포팅해 사용하고 있다. 안드로이드에서 cpp를 테스트하기 위한 testsuite. gtest를 안드로이드 용으로 포팅해 사용하고 있다.
 +====== private/protected 테스트 방법 ======
 +pravate
 +<code cpp>
 +class Foo {
 +  friend class FooTest;
 +  ...
 +};
 +
 +class FooTest : public ::testing::Test {
 + protected:
 +  ...
 +  T1 get_private_member1(Foo* obj) {
 +    return obj->private_member1_;
 +  }
 +};
 +
 +TEST_F(FooTest, Test1) {
 +  ...
 +  get_private_member1(x)
 +  ...
 +}
 +</code>
 +protected
 +<code cpp>
 +class YourClass {
 +  ...
 + protected: // protected access for testability.
 +  int DoSomethingReturningInt();
 +  ...
 +};
 +
 +// in the your_class_test.cc file:
 +class TestableYourClass : public YourClass {
 +  ...
 + public: using YourClass::DoSomethingReturningInt; // changes access rights
 +  ...
 +};
 +
 +TEST_F(YourClassTest, DoSomethingTest) {
 +  TestableYourClass obj;
 +  assertEquals(expected_value, obj.DoSomethingReturningInt());
 +}
 +</code>
  
 ====== 안드로이드에서 gtest 위치 ====== ====== 안드로이드에서 gtest 위치 ======
gtest.1295533283.txt.gz · Last modified: 2013/08/03 05:04 (external edit)