• R/O
  • SSH
  • HTTPS

iris-fmw: Commit


Commit MetaInfo

Revision274 (tree)
Time2012-01-30 09:29:26
Authorshirayanagi

Log Message

削除

Change Summary

  • delete: trunk/framework/sample/Windows/unittest/VC2005/iutest/iutest.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2005/iutest
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/iutest.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest8/gtest8.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest8
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/iutest_gtest.sln
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest9/gtest9.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest9
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest1/gtest1.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest1
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest10/gtest10.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest10
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest2/gtest2.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest2
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest3/gtest3.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest3
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest4/gtest4.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest4
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest5/gtest5.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest5
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest6/gtest6.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest6
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest7/gtest7.vcproj
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest/gtest7
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest/gtest
  • delete: trunk/framework/sample/Windows/unittest/VC2008/iutest
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/test_iutest.cpp
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample10_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/main.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3-inl.h
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.h
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample5_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.h
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample6_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.h
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample7_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/prime_tables.h
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample8_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample9_unittest.cc
  • delete: trunk/framework/sample/Windows/unittest/src/iutest/gtest
  • delete: trunk/framework/sample/Windows/unittest/src/iutest

Incremental Difference

--- trunk/framework/sample/Windows/unittest/src/iutest/test_iutest.cpp (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/test_iutest.cpp (nonexistent)
@@ -1,317 +0,0 @@
1-//======================================================================
2-//-----------------------------------------------------------------------
3-/**
4- * @file test_iutest.cpp
5- * @brief iutest テスト ファイル
6- *
7- * @author t.sirayanagi
8- * @version 1.0
9- *
10- * @par copyright
11- * Copyright (C) 2011 Takazumi Shirayanagi\n
12- * The new BSD License is applied to this software.
13- * see iris_LICENSE.txt
14-*/
15-//-----------------------------------------------------------------------
16-//======================================================================
17-#define _FILE_test_iutest_CPP_
18-
19-//======================================================================
20-// include
21-#include "iutest.h"
22-
23-IUTEST(IUTest, Test1)
24-{
25- //int* p1 = iutest::detail::iuStaticPool<int,0>::New();
26- //int* p2 = iutest::detail::iuStaticPool<int,1>::New();
27- //IUTEST_ASSERT_EQ(p1, p2);
28-}
29-
30-IUTEST(IUTest, Test2)
31-{
32-}
33-
34-IUTEST(IUTest, Test3)
35-{
36-}
37-
38-IUTEST(IUTest, Test4)
39-{
40-}
41-
42-class IUTestFixed : public iutest::Test {};
43-IUTEST_F(IUTestFixed, Test1)
44-{
45-}
46-
47-IUTEST_F(IUTestFixed, Test2)
48-{
49-}
50-
51-IUTEST_F(IUTestFixed, Test3)
52-{
53-}
54-
55-IUTEST(IUTestOp, EQ)
56-{
57- int x=0, y=0;
58- IUTEST_ASSERT_EQ(x, y);
59-}
60-
61-IUTEST(IUTestOp, NE)
62-{
63- int x=0, y=1;
64- IUTEST_ASSERT_NE(x, y);
65-}
66-
67-IUTEST(IUTestOp, LE)
68-{
69- {
70- unsigned long x=1, y=1;
71- IUTEST_ASSERT_LE(x, y);
72- }
73- {
74- double x=0, y=1;
75- IUTEST_ASSERT_LE(x, y);
76- }
77-}
78-
79-IUTEST(IUTestOp, LT)
80-{
81- double x=0, y=1;
82- IUTEST_ASSERT_LT(x, y);
83-}
84-
85-IUTEST(IUTestOp, GE)
86-{
87- {
88- unsigned long x=1, y=1;
89- IUTEST_ASSERT_GE(y, x);
90- }
91- {
92- double x=0, y=1;
93- IUTEST_ASSERT_GE(y, x);
94- }
95-}
96-
97-IUTEST(IUTestOp, GT)
98-{
99- double x=0, y=1;
100- IUTEST_ASSERT_GT(y, x);
101-}
102-
103-#ifdef _DEBUG
104-IUTEST(ClassSize, All)
105-{
106- IUTEST_EXPECT_EQ(0, sizeof(iutest::TestCase));
107- IUTEST_EXPECT_EQ(0, sizeof(iutest::TestInfo));
108-}
109-#endif
110-
111-#if 0
112-#define VALUES_TEST(name, values) \
113-class IUTestPValues##name : public iutest::TestWithParam<int> {}; \
114-IUTEST_INSTANCE_P(IUTestPValues##name##Instance, IUTestPValues##name \
115- , values); \
116-IUTEST_P(IUTestPValues##name, Test) \
117-{ static int i=1; \
118- IUTEST_ASSERT_EQ(i++, GetParam()); \
119-}
120-
121-VALUES_TEST(50, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
122- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
123- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
124- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
125- , 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
126- , 50))
127-VALUES_TEST(49, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
128- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
129- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
130- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
131- , 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
132- ))
133-VALUES_TEST(48, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
134- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
135- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
136- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
137- , 40, 41, 42, 43, 44, 45, 46, 47, 48
138- ))
139-VALUES_TEST(47, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
140- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
141- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
142- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
143- , 40, 41, 42, 43, 44, 45, 46, 47
144- ))
145-VALUES_TEST(46, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
146- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
147- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
148- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
149- , 40, 41, 42, 43, 44, 45, 46
150- ))
151-VALUES_TEST(45, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
152- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
153- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
154- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
155- , 40, 41, 42, 43, 44, 45
156- ))
157-VALUES_TEST(44, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
158- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
159- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
160- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
161- , 40, 41, 42, 43, 44
162- ))
163-VALUES_TEST(43, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
164- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
165- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
166- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
167- , 40, 41, 42, 43
168- ))
169-VALUES_TEST(42, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
170- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
171- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
172- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
173- , 40, 41, 42
174- ))
175-VALUES_TEST(41, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
176- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
177- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
178- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
179- , 40, 41
180- ))
181-VALUES_TEST(40, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
182- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
183- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
184- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
185- , 40
186- ))
187-VALUES_TEST(39, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
188- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
189- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
190- , 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
191- ))
192-VALUES_TEST(38, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
193- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
194- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
195- , 30, 31, 32, 33, 34, 35, 36, 37, 38
196- ))
197-VALUES_TEST(37, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
198- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
199- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
200- , 30, 31, 32, 33, 34, 35, 36, 37
201- ))
202-VALUES_TEST(36, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
203- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
204- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
205- , 30, 31, 32, 33, 34, 35, 36
206- ))
207-VALUES_TEST(35, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
208- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
209- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
210- , 30, 31, 32, 33, 34, 35
211- ))
212-VALUES_TEST(34, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
213- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
214- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
215- , 30, 31, 32, 33, 34
216- ))
217-VALUES_TEST(33, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
218- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
219- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
220- , 30, 31, 32, 33
221- ))
222-VALUES_TEST(32, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
223- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
224- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
225- , 30, 31, 32
226- ))
227-VALUES_TEST(31, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
228- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
229- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
230- , 30, 31
231- ))
232-VALUES_TEST(30, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
233- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
234- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
235- , 30
236- ))
237-VALUES_TEST(29, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
238- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
239- , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
240- ))
241-VALUES_TEST(28, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
242- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
243- , 20, 21, 22, 23, 24, 25, 26, 27, 28
244- ))
245-VALUES_TEST(27, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
246- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
247- , 20, 21, 22, 23, 24, 25, 26, 27
248- ))
249-VALUES_TEST(26, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
250- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
251- , 20, 21, 22, 23, 24, 25, 26
252- ))
253-VALUES_TEST(25, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
254- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
255- , 20, 21, 22, 23, 24, 25
256- ))
257-VALUES_TEST(24, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
258- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
259- , 20, 21, 22, 23, 24
260- ))
261-VALUES_TEST(23, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
262- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
263- , 20, 21, 22, 23
264- ))
265-VALUES_TEST(22, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
266- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
267- , 20, 21, 22
268- ))
269-VALUES_TEST(21, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
270- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
271- , 20, 21
272- ))
273-VALUES_TEST(20, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
274- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
275- , 20
276- ))
277-VALUES_TEST(19, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
278- , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
279- ))
280-VALUES_TEST(18, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
281- , 10, 11, 12, 13, 14, 15, 16, 17, 18
282- ))
283-VALUES_TEST(17, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
284- , 10, 11, 12, 13, 14, 15, 16, 17
285- ))
286-VALUES_TEST(16, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
287- , 10, 11, 12, 13, 14, 15, 16
288- ))
289-VALUES_TEST(15, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
290- , 10, 11, 12, 13, 14, 15
291- ))
292-VALUES_TEST(14, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
293- , 10, 11, 12, 13, 14
294- ))
295-VALUES_TEST(13, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
296- , 10, 11, 12, 13
297- ))
298-VALUES_TEST(12, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
299- , 10, 11, 12
300- ))
301-VALUES_TEST(11, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
302- , 10, 11
303- ))
304-VALUES_TEST(10, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9
305- , 10
306- ))
307-VALUES_TEST( 9, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8, 9))
308-VALUES_TEST( 8, iutest::Values(1, 2, 3, 4, 5, 6, 7, 8))
309-VALUES_TEST( 7, iutest::Values(1, 2, 3, 4, 5, 6, 7))
310-VALUES_TEST( 6, iutest::Values(1, 2, 3, 4, 5, 6))
311-VALUES_TEST( 5, iutest::Values(1, 2, 3, 4, 5))
312-VALUES_TEST( 4, iutest::Values(1, 2, 3, 4))
313-VALUES_TEST( 3, iutest::Values(1, 2, 3))
314-VALUES_TEST( 2, iutest::Values(1, 2))
315-VALUES_TEST( 1, iutest::Values(1))
316-
317-#endif
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/main.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/main.cc (nonexistent)
@@ -1,9 +0,0 @@
1-#include <stdio.h>
2-
3-#include "gtest/gtest.h"
4-#include "gtest/iutest_switch.h"
5-
6-int main(int argc, char **argv) {
7- testing::InitGoogleTest(&argc, argv);
8- return RUN_ALL_TESTS();
9-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3-inl.h (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3-inl.h (nonexistent)
@@ -1,173 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#ifndef GTEST_SAMPLES_SAMPLE3_INL_H_
35-#define GTEST_SAMPLES_SAMPLE3_INL_H_
36-
37-#include <stddef.h>
38-
39-
40-// Queue is a simple queue implemented as a singled-linked list.
41-//
42-// The element type must support copy constructor.
43-template <typename E> // E is the element type
44-class Queue;
45-
46-// QueueNode is a node in a Queue, which consists of an element of
47-// type E and a pointer to the next node.
48-template <typename E> // E is the element type
49-class QueueNode {
50- friend class Queue<E>;
51-
52- public:
53- // Gets the element in this node.
54- const E& element() const { return element_; }
55-
56- // Gets the next node in the queue.
57- QueueNode* next() { return next_; }
58- const QueueNode* next() const { return next_; }
59-
60- private:
61- // Creates a node with a given element value. The next pointer is
62- // set to NULL.
63- QueueNode(const E& an_element) : element_(an_element), next_(NULL) {}
64-
65- // We disable the default assignment operator and copy c'tor.
66- const QueueNode& operator = (const QueueNode&);
67- QueueNode(const QueueNode&);
68-
69- E element_;
70- QueueNode* next_;
71-};
72-
73-template <typename E> // E is the element type.
74-class Queue {
75-public:
76-
77- // Creates an empty queue.
78- Queue() : head_(NULL), last_(NULL), size_(0) {}
79-
80- // D'tor. Clears the queue.
81- ~Queue() { Clear(); }
82-
83- // Clears the queue.
84- void Clear() {
85- if (size_ > 0) {
86- // 1. Deletes every node.
87- QueueNode<E>* node = head_;
88- QueueNode<E>* next = node->next();
89- for (; ;) {
90- delete node;
91- node = next;
92- if (node == NULL) break;
93- next = node->next();
94- }
95-
96- // 2. Resets the member variables.
97- head_ = last_ = NULL;
98- size_ = 0;
99- }
100- }
101-
102- // Gets the number of elements.
103- size_t Size() const { return size_; }
104-
105- // Gets the first element of the queue, or NULL if the queue is empty.
106- QueueNode<E>* Head() { return head_; }
107- const QueueNode<E>* Head() const { return head_; }
108-
109- // Gets the last element of the queue, or NULL if the queue is empty.
110- QueueNode<E>* Last() { return last_; }
111- const QueueNode<E>* Last() const { return last_; }
112-
113- // Adds an element to the end of the queue. A copy of the element is
114- // created using the copy constructor, and then stored in the queue.
115- // Changes made to the element in the queue doesn't affect the source
116- // object, and vice versa.
117- void Enqueue(const E& element) {
118- QueueNode<E>* new_node = new QueueNode<E>(element);
119-
120- if (size_ == 0) {
121- head_ = last_ = new_node;
122- size_ = 1;
123- } else {
124- last_->next_ = new_node;
125- last_ = new_node;
126- size_++;
127- }
128- }
129-
130- // Removes the head of the queue and returns it. Returns NULL if
131- // the queue is empty.
132- E* Dequeue() {
133- if (size_ == 0) {
134- return NULL;
135- }
136-
137- const QueueNode<E>* const old_head = head_;
138- head_ = head_->next_;
139- size_--;
140- if (size_ == 0) {
141- last_ = NULL;
142- }
143-
144- E* element = new E(old_head->element());
145- delete old_head;
146-
147- return element;
148- }
149-
150- // Applies a function/functor on each element of the queue, and
151- // returns the result in a new queue. The original queue is not
152- // affected.
153- template <typename F>
154- Queue* Map(F function) const {
155- Queue* new_queue = new Queue();
156- for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {
157- new_queue->Enqueue(function(node->element()));
158- }
159-
160- return new_queue;
161- }
162-
163- private:
164- QueueNode<E>* head_; // The first node of the queue.
165- QueueNode<E>* last_; // The last node of the queue.
166- size_t size_; // The number of elements in the queue.
167-
168- // We disallow copying a queue.
169- Queue(const Queue&);
170- const Queue& operator = (const Queue&);
171- };
172-
173-#endif // GTEST_SAMPLES_SAMPLE3_INL_H_
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1_unittest.cc (nonexistent)
@@ -1,154 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-
35-// This sample shows how to write a simple unit test for a function,
36-// using Google C++ testing framework.
37-//
38-// Writing a unit test using Google C++ testing framework is easy as 1-2-3:
39-
40-
41-// Step 1. Include necessary header files such that the stuff your
42-// test logic needs is declared.
43-//
44-// Don't forget gtest.h, which declares the testing framework.
45-
46-#include <limits.h>
47-#include "sample1.h"
48-//#include "gtest/gtest.h"
49-#include "gtest/iutest_switch.h"
50-
51-
52-// Step 2. Use the TEST macro to define your tests.
53-//
54-// TEST has two parameters: the test case name and the test name.
55-// After using the macro, you should define your test logic between a
56-// pair of braces. You can use a bunch of macros to indicate the
57-// success or failure of a test. EXPECT_TRUE and EXPECT_EQ are
58-// examples of such macros. For a complete list, see gtest.h.
59-//
60-// <TechnicalDetails>
61-//
62-// In Google Test, tests are grouped into test cases. This is how we
63-// keep test code organized. You should put logically related tests
64-// into the same test case.
65-//
66-// The test case name and the test name should both be valid C++
67-// identifiers. And you should not use underscore (_) in the names.
68-//
69-// Google Test guarantees that each test you define is run exactly
70-// once, but it makes no guarantee on the order the tests are
71-// executed. Therefore, you should write your tests in such a way
72-// that their results don't depend on their order.
73-//
74-// </TechnicalDetails>
75-
76-
77-// Tests Factorial().
78-
79-// Tests factorial of negative numbers.
80-TEST(FactorialTest, Negative) {
81- // This test is named "Negative", and belongs to the "FactorialTest"
82- // test case.
83- EXPECT_EQ(1, Factorial(-5));
84- EXPECT_EQ(1, Factorial(-1));
85- EXPECT_TRUE(Factorial(-10) > 0);
86-
87- // <TechnicalDetails>
88- //
89- // EXPECT_EQ(expected, actual) is the same as
90- //
91- // EXPECT_TRUE((expected) == (actual))
92- //
93- // except that it will print both the expected value and the actual
94- // value when the assertion fails. This is very helpful for
95- // debugging. Therefore in this case EXPECT_EQ is preferred.
96- //
97- // On the other hand, EXPECT_TRUE accepts any Boolean expression,
98- // and is thus more general.
99- //
100- // </TechnicalDetails>
101-}
102-
103-// Tests factorial of 0.
104-TEST(FactorialTest, Zero) {
105- EXPECT_EQ(1, Factorial(0));
106-}
107-
108-// Tests factorial of positive numbers.
109-TEST(FactorialTest, Positive) {
110- EXPECT_EQ(1, Factorial(1));
111- EXPECT_EQ(2, Factorial(2));
112- EXPECT_EQ(6, Factorial(3));
113- EXPECT_EQ(40320, Factorial(8));
114-}
115-
116-
117-// Tests IsPrime()
118-
119-// Tests negative input.
120-TEST(IsPrimeTest, Negative) {
121- // This test belongs to the IsPrimeTest test case.
122-
123- EXPECT_FALSE(IsPrime(-1));
124- EXPECT_FALSE(IsPrime(-2));
125- EXPECT_FALSE(IsPrime(INT_MIN));
126-}
127-
128-// Tests some trivial cases.
129-TEST(IsPrimeTest, Trivial) {
130- EXPECT_FALSE(IsPrime(0));
131- EXPECT_FALSE(IsPrime(1));
132- EXPECT_TRUE(IsPrime(2));
133- EXPECT_TRUE(IsPrime(3));
134-}
135-
136-// Tests positive input.
137-TEST(IsPrimeTest, Positive) {
138- EXPECT_FALSE(IsPrime(4));
139- EXPECT_TRUE(IsPrime(5));
140- EXPECT_FALSE(IsPrime(6));
141- EXPECT_TRUE(IsPrime(23));
142-}
143-
144-// Step 3. Call RUN_ALL_TESTS() in main().
145-//
146-// We do this by linking in src/gtest_main.cc file, which consists of
147-// a main() function which calls RUN_ALL_TESTS() for us.
148-//
149-// This runs all the tests you've defined, prints the result, and
150-// returns 0 if successful, or 1 otherwise.
151-//
152-// Did you notice that we didn't register the tests? The
153-// RUN_ALL_TESTS() macro magically knows about all the tests we
154-// defined. Isn't this convenient?
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2_unittest.cc (nonexistent)
@@ -1,110 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-
35-// This sample shows how to write a more complex unit test for a class
36-// that has multiple member functions.
37-//
38-// Usually, it's a good idea to have one test for each method in your
39-// class. You don't have to do that exactly, but it helps to keep
40-// your tests organized. You may also throw in additional tests as
41-// needed.
42-
43-#include "sample2.h"
44-//#include "gtest/gtest.h"
45-#include "gtest/iutest_switch.h"
46-
47-// In this example, we test the MyString class (a simple string).
48-
49-// Tests the default c'tor.
50-TEST(MyString, DefaultConstructor) {
51- const MyString s;
52-
53- // Asserts that s.c_string() returns NULL.
54- //
55- // <TechnicalDetails>
56- //
57- // If we write NULL instead of
58- //
59- // static_cast<const char *>(NULL)
60- //
61- // in this assertion, it will generate a warning on gcc 3.4. The
62- // reason is that EXPECT_EQ needs to know the types of its
63- // arguments in order to print them when it fails. Since NULL is
64- // #defined as 0, the compiler will use the formatter function for
65- // int to print it. However, gcc thinks that NULL should be used as
66- // a pointer, not an int, and therefore complains.
67- //
68- // The root of the problem is C++'s lack of distinction between the
69- // integer number 0 and the null pointer constant. Unfortunately,
70- // we have to live with this fact.
71- //
72- // </TechnicalDetails>
73- EXPECT_STREQ(NULL, s.c_string());
74-
75- EXPECT_EQ(0u, s.Length());
76-}
77-
78-const char kHelloString[] = "Hello, world!";
79-
80-// Tests the c'tor that accepts a C string.
81-TEST(MyString, ConstructorFromCString) {
82- const MyString s(kHelloString);
83- EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
84- EXPECT_EQ(sizeof(kHelloString)/sizeof(kHelloString[0]) - 1,
85- s.Length());
86-}
87-
88-// Tests the copy c'tor.
89-TEST(MyString, CopyConstructor) {
90- const MyString s1(kHelloString);
91- const MyString s2 = s1;
92- EXPECT_TRUE(strcmp(s2.c_string(), kHelloString) == 0);
93-}
94-
95-// Tests the Set method.
96-TEST(MyString, Set) {
97- MyString s;
98-
99- s.Set(kHelloString);
100- EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
101-
102- // Set should work when the input pointer is the same as the one
103- // already in the MyString object.
104- s.Set(s.c_string());
105- EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
106-
107- // Can we set the MyString to NULL?
108- s.Set(NULL);
109- EXPECT_STREQ(NULL, s.c_string());
110-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.cc (nonexistent)
@@ -1,68 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#include "sample1.h"
35-
36-// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
37-int Factorial(int n) {
38- int result = 1;
39- for (int i = 1; i <= n; i++) {
40- result *= i;
41- }
42-
43- return result;
44-}
45-
46-// Returns true iff n is a prime number.
47-bool IsPrime(int n) {
48- // Trivial case 1: small numbers
49- if (n <= 1) return false;
50-
51- // Trivial case 2: even numbers
52- if (n % 2 == 0) return n == 2;
53-
54- // Now, we have that n is odd and n >= 3.
55-
56- // Try to divide n by every odd number i, starting from 3
57- for (int i = 3; ; i += 2) {
58- // We only have to try i up to the squre root of n
59- if (i > n/i) break;
60-
61- // Now, we have i <= n/i < n.
62- // If n is divisible by i, n is not prime.
63- if (n % i == 0) return false;
64- }
65-
66- // n has no integer factor in the range (1, n), and thus is prime.
67- return true;
68-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample3_unittest.cc (nonexistent)
@@ -1,152 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-
35-// In this example, we use a more advanced feature of Google Test called
36-// test fixture.
37-//
38-// A test fixture is a place to hold objects and functions shared by
39-// all tests in a test case. Using a test fixture avoids duplicating
40-// the test code necessary to initialize and cleanup those common
41-// objects for each test. It is also useful for defining sub-routines
42-// that your tests need to invoke a lot.
43-//
44-// <TechnicalDetails>
45-//
46-// The tests share the test fixture in the sense of code sharing, not
47-// data sharing. Each test is given its own fresh copy of the
48-// fixture. You cannot expect the data modified by one test to be
49-// passed on to another test, which is a bad idea.
50-//
51-// The reason for this design is that tests should be independent and
52-// repeatable. In particular, a test should not fail as the result of
53-// another test's failure. If one test depends on info produced by
54-// another test, then the two tests should really be one big test.
55-//
56-// The macros for indicating the success/failure of a test
57-// (EXPECT_TRUE, FAIL, etc) need to know what the current test is
58-// (when Google Test prints the test result, it tells you which test
59-// each failure belongs to). Technically, these macros invoke a
60-// member function of the Test class. Therefore, you cannot use them
61-// in a global function. That's why you should put test sub-routines
62-// in a test fixture.
63-//
64-// </TechnicalDetails>
65-
66-#include "sample3-inl.h"
67-//#include "gtest/gtest.h"
68-#include "gtest/iutest_switch.h"
69-
70-// To use a test fixture, derive a class from testing::Test.
71-class QueueTest : public testing::Test {
72- protected: // You should make the members protected s.t. they can be
73- // accessed from sub-classes.
74-
75- // virtual void SetUp() will be called before each test is run. You
76- // should define it if you need to initialize the varaibles.
77- // Otherwise, this can be skipped.
78- virtual void SetUp() {
79- q1_.Enqueue(1);
80- q2_.Enqueue(2);
81- q2_.Enqueue(3);
82- }
83-
84- // virtual void TearDown() will be called after each test is run.
85- // You should define it if there is cleanup work to do. Otherwise,
86- // you don't have to provide it.
87- //
88- // virtual void TearDown() {
89- // }
90-
91- // A helper function that some test uses.
92- static int Double(int n) {
93- return 2*n;
94- }
95-
96- // A helper function for testing Queue::Map().
97- void MapTester(const Queue<int> * q) {
98- // Creates a new queue, where each element is twice as big as the
99- // corresponding one in q.
100- const Queue<int> * const new_q = q->Map(Double);
101-
102- // Verifies that the new queue has the same size as q.
103- ASSERT_EQ(q->Size(), new_q->Size());
104-
105- // Verifies the relationship between the elements of the two queues.
106- for ( const QueueNode<int> * n1 = q->Head(), * n2 = new_q->Head();
107- n1 != NULL; n1 = n1->next(), n2 = n2->next() ) {
108- EXPECT_EQ(2 * n1->element(), n2->element());
109- }
110-
111- delete new_q;
112- }
113-
114- // Declares the variables your tests want to use.
115- Queue<int> q0_;
116- Queue<int> q1_;
117- Queue<int> q2_;
118-};
119-
120-// When you have a test fixture, you define a test using TEST_F
121-// instead of TEST.
122-
123-// Tests the default c'tor.
124-TEST_F(QueueTest, DefaultConstructor) {
125- // You can access data in the test fixture here.
126- EXPECT_EQ(0u, q0_.Size());
127-}
128-
129-// Tests Dequeue().
130-TEST_F(QueueTest, Dequeue) {
131- int * n = q0_.Dequeue();
132- EXPECT_TRUE(n == NULL);
133-
134- n = q1_.Dequeue();
135- ASSERT_TRUE(n != NULL);
136- EXPECT_EQ(1, *n);
137- EXPECT_EQ(0u, q1_.Size());
138- delete n;
139-
140- n = q2_.Dequeue();
141- ASSERT_TRUE(n != NULL);
142- EXPECT_EQ(2, *n);
143- EXPECT_EQ(1u, q2_.Size());
144- delete n;
145-}
146-
147-// Tests the Queue::Map() function.
148-TEST_F(QueueTest, Map) {
149- MapTester(&q0_);
150- MapTester(&q1_);
151- MapTester(&q2_);
152-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.cc (nonexistent)
@@ -1,56 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#include "sample2.h"
35-
36-#include <string.h>
37-
38-// Clones a 0-terminated C string, allocating memory using new.
39-const char* MyString::CloneCString(const char* a_c_string) {
40- if (a_c_string == NULL) return NULL;
41-
42- const size_t len = strlen(a_c_string);
43- char* const clone = new char[ len + 1 ];
44- memcpy(clone, a_c_string, len + 1);
45-
46- return clone;
47-}
48-
49-// Sets the 0-terminated C string this MyString object
50-// represents.
51-void MyString::Set(const char* a_c_string) {
52- // Makes sure this works when c_string == c_string_
53- const char* const temp = MyString::CloneCString(a_c_string);
54- delete[] c_string_;
55- c_string_ = temp;
56-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4_unittest.cc (nonexistent)
@@ -1,46 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: wan@google.com (Zhanyong Wan)
31-
32-//#include "gtest/gtest.h"
33-#include "gtest/iutest_switch.h"
34-#include "sample4.h"
35-
36-// Tests the Increment() method.
37-TEST(Counter, Increment) {
38- Counter c;
39-
40- // EXPECT_EQ() evaluates its arguments exactly once, so they
41- // can have side effects.
42-
43- EXPECT_EQ(0, c.Increment());
44- EXPECT_EQ(1, c.Increment());
45- EXPECT_EQ(2, c.Increment());
46-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.h (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample1.h (nonexistent)
@@ -1,43 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#ifndef GTEST_SAMPLES_SAMPLE1_H_
35-#define GTEST_SAMPLES_SAMPLE1_H_
36-
37-// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
38-int Factorial(int n);
39-
40-// Returns true iff n is a prime number.
41-bool IsPrime(int n);
42-
43-#endif // GTEST_SAMPLES_SAMPLE1_H_
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample5_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample5_unittest.cc (nonexistent)
@@ -1,200 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: wan@google.com (Zhanyong Wan)
31-
32-// This sample teaches how to reuse a test fixture in multiple test
33-// cases by deriving sub-fixtures from it.
34-//
35-// When you define a test fixture, you specify the name of the test
36-// case that will use this fixture. Therefore, a test fixture can
37-// be used by only one test case.
38-//
39-// Sometimes, more than one test cases may want to use the same or
40-// slightly different test fixtures. For example, you may want to
41-// make sure that all tests for a GUI library don't leak important
42-// system resources like fonts and brushes. In Google Test, you do
43-// this by putting the shared logic in a super (as in "super class")
44-// test fixture, and then have each test case use a fixture derived
45-// from this super fixture.
46-
47-#include <limits.h>
48-#include <time.h>
49-#include "sample3-inl.h"
50-//#include "gtest/gtest.h"
51-#include "gtest/iutest_switch.h"
52-#include "sample1.h"
53-
54-// In this sample, we want to ensure that every test finishes within
55-// ~5 seconds. If a test takes longer to run, we consider it a
56-// failure.
57-//
58-// We put the code for timing a test in a test fixture called
59-// "QuickTest". QuickTest is intended to be the super fixture that
60-// other fixtures derive from, therefore there is no test case with
61-// the name "QuickTest". This is OK.
62-//
63-// Later, we will derive multiple test fixtures from QuickTest.
64-class QuickTest : public testing::Test {
65- protected:
66- // Remember that SetUp() is run immediately before a test starts.
67- // This is a good place to record the start time.
68- virtual void SetUp() {
69- start_time_ = time(NULL);
70- }
71-
72- // TearDown() is invoked immediately after a test finishes. Here we
73- // check if the test was too slow.
74- virtual void TearDown() {
75- // Gets the time when the test finishes
76- const time_t end_time = time(NULL);
77-
78- // Asserts that the test took no more than ~5 seconds. Did you
79- // know that you can use assertions in SetUp() and TearDown() as
80- // well?
81- EXPECT_TRUE(end_time - start_time_ <= 5) << "The test took too long.";
82- }
83-
84- // The UTC time (in seconds) when the test starts
85- time_t start_time_;
86-};
87-
88-
89-// We derive a fixture named IntegerFunctionTest from the QuickTest
90-// fixture. All tests using this fixture will be automatically
91-// required to be quick.
92-class IntegerFunctionTest : public QuickTest {
93- // We don't need any more logic than already in the QuickTest fixture.
94- // Therefore the body is empty.
95-};
96-
97-
98-// Now we can write tests in the IntegerFunctionTest test case.
99-
100-// Tests Factorial()
101-TEST_F(IntegerFunctionTest, Factorial) {
102- // Tests factorial of negative numbers.
103- EXPECT_EQ(1, Factorial(-5));
104- EXPECT_EQ(1, Factorial(-1));
105- EXPECT_TRUE(Factorial(-10) > 0);
106-
107- // Tests factorial of 0.
108- EXPECT_EQ(1, Factorial(0));
109-
110- // Tests factorial of positive numbers.
111- EXPECT_EQ(1, Factorial(1));
112- EXPECT_EQ(2, Factorial(2));
113- EXPECT_EQ(6, Factorial(3));
114- EXPECT_EQ(40320, Factorial(8));
115-}
116-
117-
118-// Tests IsPrime()
119-TEST_F(IntegerFunctionTest, IsPrime) {
120- // Tests negative input.
121- EXPECT_TRUE(!IsPrime(-1));
122- EXPECT_TRUE(!IsPrime(-2));
123- EXPECT_TRUE(!IsPrime(INT_MIN));
124-
125- // Tests some trivial cases.
126- EXPECT_TRUE(!IsPrime(0));
127- EXPECT_TRUE(!IsPrime(1));
128- EXPECT_TRUE(IsPrime(2));
129- EXPECT_TRUE(IsPrime(3));
130-
131- // Tests positive input.
132- EXPECT_TRUE(!IsPrime(4));
133- EXPECT_TRUE(IsPrime(5));
134- EXPECT_TRUE(!IsPrime(6));
135- EXPECT_TRUE(IsPrime(23));
136-}
137-
138-
139-// The next test case (named "QueueTest") also needs to be quick, so
140-// we derive another fixture from QuickTest.
141-//
142-// The QueueTest test fixture has some logic and shared objects in
143-// addition to what's in QuickTest already. We define the additional
144-// stuff inside the body of the test fixture, as usual.
145-class QueueTest : public QuickTest {
146- protected:
147- virtual void SetUp() {
148- // First, we need to set up the super fixture (QuickTest).
149- QuickTest::SetUp();
150-
151- // Second, some additional setup for this fixture.
152- q1_.Enqueue(1);
153- q2_.Enqueue(2);
154- q2_.Enqueue(3);
155- }
156-
157- // By default, TearDown() inherits the behavior of
158- // QuickTest::TearDown(). As we have no additional cleaning work
159- // for QueueTest, we omit it here.
160- //
161- // virtual void TearDown() {
162- // QuickTest::TearDown();
163- // }
164-
165- Queue<int> q0_;
166- Queue<int> q1_;
167- Queue<int> q2_;
168-};
169-
170-
171-// Now, let's write tests using the QueueTest fixture.
172-
173-// Tests the default constructor.
174-TEST_F(QueueTest, DefaultConstructor) {
175- EXPECT_EQ(0u, q0_.Size());
176-}
177-
178-// Tests Dequeue().
179-TEST_F(QueueTest, Dequeue) {
180- int* n = q0_.Dequeue();
181- EXPECT_TRUE(n == NULL);
182-
183- n = q1_.Dequeue();
184- EXPECT_TRUE(n != NULL);
185- EXPECT_EQ(1, *n);
186- EXPECT_EQ(0u, q1_.Size());
187- delete n;
188-
189- n = q2_.Dequeue();
190- EXPECT_TRUE(n != NULL);
191- EXPECT_EQ(2, *n);
192- EXPECT_EQ(1u, q2_.Size());
193- delete n;
194-}
195-
196-// If necessary, you can derive further test fixtures from a derived
197-// fixture itself. For example, you can derive another fixture from
198-// QueueTest. Google Test imposes no limit on how deep the hierarchy
199-// can be. In practice, however, you probably don't want it to be too
200-// deep as to be confusing.
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.h (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample2.h (nonexistent)
@@ -1,86 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#ifndef GTEST_SAMPLES_SAMPLE2_H_
35-#define GTEST_SAMPLES_SAMPLE2_H_
36-
37-#include <string.h>
38-
39-
40-// A simple string class.
41-class MyString {
42- private:
43- const char* c_string_;
44- const MyString& operator=(const MyString& rhs);
45-
46- public:
47-
48- // Clones a 0-terminated C string, allocating memory using new.
49- static const char* CloneCString(const char* a_c_string);
50-
51- ////////////////////////////////////////////////////////////
52- //
53- // C'tors
54-
55- // The default c'tor constructs a NULL string.
56- MyString() : c_string_(NULL) {}
57-
58- // Constructs a MyString by cloning a 0-terminated C string.
59- explicit MyString(const char* a_c_string) : c_string_(NULL) {
60- Set(a_c_string);
61- }
62-
63- // Copy c'tor
64- MyString(const MyString& string) : c_string_(NULL) {
65- Set(string.c_string_);
66- }
67-
68- ////////////////////////////////////////////////////////////
69- //
70- // D'tor. MyString is intended to be a final class, so the d'tor
71- // doesn't need to be virtual.
72- ~MyString() { delete[] c_string_; }
73-
74- // Gets the 0-terminated C string this MyString object represents.
75- const char* c_string() const { return c_string_; }
76-
77- size_t Length() const {
78- return c_string_ == NULL ? 0 : strlen(c_string_);
79- }
80-
81- // Sets the 0-terminated C string this MyString object represents.
82- void Set(const char* c_string);
83-};
84-
85-
86-#endif // GTEST_SAMPLES_SAMPLE2_H_
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.cc (nonexistent)
@@ -1,46 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#include <stdio.h>
35-
36-#include "sample4.h"
37-
38-// Returns the current counter value, and increments it.
39-int Counter::Increment() {
40- return counter_++;
41-}
42-
43-// Prints the current counter value to STDOUT.
44-void Counter::Print() const {
45- printf("%d", counter_);
46-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample6_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample6_unittest.cc (nonexistent)
@@ -1,225 +0,0 @@
1-// Copyright 2008 Google Inc.
2-// All Rights Reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: wan@google.com (Zhanyong Wan)
31-
32-// This sample shows how to test common properties of multiple
33-// implementations of the same interface (aka interface tests).
34-
35-// The interface and its implementations are in this header.
36-#include "prime_tables.h"
37-
38-//#include "gtest/gtest.h"
39-#include "gtest/iutest_switch.h"
40-
41-// First, we define some factory functions for creating instances of
42-// the implementations. You may be able to skip this step if all your
43-// implementations can be constructed the same way.
44-
45-template <class T>
46-PrimeTable* CreatePrimeTable();
47-
48-template <>
49-PrimeTable* CreatePrimeTable<OnTheFlyPrimeTable>() {
50- return new OnTheFlyPrimeTable;
51-}
52-
53-template <>
54-PrimeTable* CreatePrimeTable<PreCalculatedPrimeTable>() {
55- return new PreCalculatedPrimeTable(10000);
56-}
57-
58-// Then we define a test fixture class template.
59-template <class T>
60-class PrimeTableTest : public testing::Test {
61- protected:
62- // The ctor calls the factory function to create a prime table
63- // implemented by T.
64- PrimeTableTest() : table_(CreatePrimeTable<T>()) {}
65-
66- virtual ~PrimeTableTest() { delete table_; }
67-
68- // Note that we test an implementation via the base interface
69- // instead of the actual implementation class. This is important
70- // for keeping the tests close to the real world scenario, where the
71- // implementation is invoked via the base interface. It avoids
72- // got-yas where the implementation class has a method that shadows
73- // a method with the same name (but slightly different argument
74- // types) in the base interface, for example.
75- PrimeTable* const table_;
76-};
77-
78-#if GTEST_HAS_TYPED_TEST
79-
80-using testing::Types;
81-
82-// Google Test offers two ways for reusing tests for different types.
83-// The first is called "typed tests". You should use it if you
84-// already know *all* the types you are gonna exercise when you write
85-// the tests.
86-
87-// To write a typed test case, first use
88-//
89-// TYPED_TEST_CASE(TestCaseName, TypeList);
90-//
91-// to declare it and specify the type parameters. As with TEST_F,
92-// TestCaseName must match the test fixture name.
93-
94-// The list of types we want to test.
95-typedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable> Implementations;
96-
97-TYPED_TEST_CASE(PrimeTableTest, Implementations);
98-
99-// Then use TYPED_TEST(TestCaseName, TestName) to define a typed test,
100-// similar to TEST_F.
101-TYPED_TEST(PrimeTableTest, ReturnsFalseForNonPrimes) {
102- // Inside the test body, you can refer to the type parameter by
103- // TypeParam, and refer to the fixture class by TestFixture. We
104- // don't need them in this example.
105-
106- // Since we are in the template world, C++ requires explicitly
107- // writing 'this->' when referring to members of the fixture class.
108- // This is something you have to learn to live with.
109- EXPECT_FALSE(this->table_->IsPrime(-5));
110- EXPECT_FALSE(this->table_->IsPrime(0));
111- EXPECT_FALSE(this->table_->IsPrime(1));
112- EXPECT_FALSE(this->table_->IsPrime(4));
113- EXPECT_FALSE(this->table_->IsPrime(6));
114- EXPECT_FALSE(this->table_->IsPrime(100));
115-}
116-
117-TYPED_TEST(PrimeTableTest, ReturnsTrueForPrimes) {
118- EXPECT_TRUE(this->table_->IsPrime(2));
119- EXPECT_TRUE(this->table_->IsPrime(3));
120- EXPECT_TRUE(this->table_->IsPrime(5));
121- EXPECT_TRUE(this->table_->IsPrime(7));
122- EXPECT_TRUE(this->table_->IsPrime(11));
123- EXPECT_TRUE(this->table_->IsPrime(131));
124-}
125-
126-TYPED_TEST(PrimeTableTest, CanGetNextPrime) {
127- EXPECT_EQ(2, this->table_->GetNextPrime(0));
128- EXPECT_EQ(3, this->table_->GetNextPrime(2));
129- EXPECT_EQ(5, this->table_->GetNextPrime(3));
130- EXPECT_EQ(7, this->table_->GetNextPrime(5));
131- EXPECT_EQ(11, this->table_->GetNextPrime(7));
132- EXPECT_EQ(131, this->table_->GetNextPrime(128));
133-}
134-
135-// That's it! Google Test will repeat each TYPED_TEST for each type
136-// in the type list specified in TYPED_TEST_CASE. Sit back and be
137-// happy that you don't have to define them multiple times.
138-
139-#endif // GTEST_HAS_TYPED_TEST
140-
141-#if GTEST_HAS_TYPED_TEST_P
142-
143-using testing::Types;
144-
145-// Sometimes, however, you don't yet know all the types that you want
146-// to test when you write the tests. For example, if you are the
147-// author of an interface and expect other people to implement it, you
148-// might want to write a set of tests to make sure each implementation
149-// conforms to some basic requirements, but you don't know what
150-// implementations will be written in the future.
151-//
152-// How can you write the tests without committing to the type
153-// parameters? That's what "type-parameterized tests" can do for you.
154-// It is a bit more involved than typed tests, but in return you get a
155-// test pattern that can be reused in many contexts, which is a big
156-// win. Here's how you do it:
157-
158-// First, define a test fixture class template. Here we just reuse
159-// the PrimeTableTest fixture defined earlier:
160-
161-template <class T>
162-class PrimeTableTest2 : public PrimeTableTest<T> {
163-};
164-
165-// Then, declare the test case. The argument is the name of the test
166-// fixture, and also the name of the test case (as usual). The _P
167-// suffix is for "parameterized" or "pattern".
168-TYPED_TEST_CASE_P(PrimeTableTest2);
169-
170-// Next, use TYPED_TEST_P(TestCaseName, TestName) to define a test,
171-// similar to what you do with TEST_F.
172-TYPED_TEST_P(PrimeTableTest2, ReturnsFalseForNonPrimes) {
173- EXPECT_FALSE(this->table_->IsPrime(-5));
174- EXPECT_FALSE(this->table_->IsPrime(0));
175- EXPECT_FALSE(this->table_->IsPrime(1));
176- EXPECT_FALSE(this->table_->IsPrime(4));
177- EXPECT_FALSE(this->table_->IsPrime(6));
178- EXPECT_FALSE(this->table_->IsPrime(100));
179-}
180-
181-TYPED_TEST_P(PrimeTableTest2, ReturnsTrueForPrimes) {
182- EXPECT_TRUE(this->table_->IsPrime(2));
183- EXPECT_TRUE(this->table_->IsPrime(3));
184- EXPECT_TRUE(this->table_->IsPrime(5));
185- EXPECT_TRUE(this->table_->IsPrime(7));
186- EXPECT_TRUE(this->table_->IsPrime(11));
187- EXPECT_TRUE(this->table_->IsPrime(131));
188-}
189-
190-TYPED_TEST_P(PrimeTableTest2, CanGetNextPrime) {
191- EXPECT_EQ(2, this->table_->GetNextPrime(0));
192- EXPECT_EQ(3, this->table_->GetNextPrime(2));
193- EXPECT_EQ(5, this->table_->GetNextPrime(3));
194- EXPECT_EQ(7, this->table_->GetNextPrime(5));
195- EXPECT_EQ(11, this->table_->GetNextPrime(7));
196- EXPECT_EQ(131, this->table_->GetNextPrime(128));
197-}
198-
199-// Type-parameterized tests involve one extra step: you have to
200-// enumerate the tests you defined:
201-REGISTER_TYPED_TEST_CASE_P(
202- PrimeTableTest2, // The first argument is the test case name.
203- // The rest of the arguments are the test names.
204- ReturnsFalseForNonPrimes, ReturnsTrueForPrimes, CanGetNextPrime);
205-
206-// At this point the test pattern is done. However, you don't have
207-// any real test yet as you haven't said which types you want to run
208-// the tests with.
209-
210-// To turn the abstract test pattern into real tests, you instantiate
211-// it with a list of types. Usually the test pattern will be defined
212-// in a .h file, and anyone can #include and instantiate it. You can
213-// even instantiate it more than once in the same program. To tell
214-// different instances apart, you give each of them a name, which will
215-// become part of the test case name and can be used in test filters.
216-
217-// The list of types we want to test. Note that it doesn't have to be
218-// defined at the time we write the TYPED_TEST_P()s.
219-typedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable>
220- PrimeTableImplementations;
221-INSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated, // Instance name
222- PrimeTableTest2, // Test case name
223- PrimeTableImplementations); // Type list
224-
225-#endif // GTEST_HAS_TYPED_TEST_P
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.h (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample4.h (nonexistent)
@@ -1,53 +0,0 @@
1-// Copyright 2005, Google Inc.
2-// All rights reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
30-// A sample program demonstrating using Google C++ testing framework.
31-//
32-// Author: wan@google.com (Zhanyong Wan)
33-
34-#ifndef GTEST_SAMPLES_SAMPLE4_H_
35-#define GTEST_SAMPLES_SAMPLE4_H_
36-
37-// A simple monotonic counter.
38-class Counter {
39- private:
40- int counter_;
41-
42- public:
43- // Creates a counter that starts at 0.
44- Counter() : counter_(0) {}
45-
46- // Returns the current counter value, and increments it.
47- int Increment();
48-
49- // Prints the current counter value to STDOUT.
50- void Print() const;
51-};
52-
53-#endif // GTEST_SAMPLES_SAMPLE4_H_
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample7_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample7_unittest.cc (nonexistent)
@@ -1,131 +0,0 @@
1-// Copyright 2008 Google Inc.
2-// All Rights Reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: vladl@google.com (Vlad Losev)
31-
32-// This sample shows how to test common properties of multiple
33-// implementations of an interface (aka interface tests) using
34-// value-parameterized tests. Each test in the test case has
35-// a parameter that is an interface pointer to an implementation
36-// tested.
37-
38-// The interface and its implementations are in this header.
39-#include "prime_tables.h"
40-
41-//#include "gtest/gtest.h"
42-#include "gtest/iutest_switch.h"
43-
44-#if GTEST_HAS_PARAM_TEST
45-
46-using ::testing::TestWithParam;
47-using ::testing::Values;
48-
49-// As a general rule, to prevent a test from affecting the tests that come
50-// after it, you should create and destroy the tested objects for each test
51-// instead of reusing them. In this sample we will define a simple factory
52-// function for PrimeTable objects. We will instantiate objects in test's
53-// SetUp() method and delete them in TearDown() method.
54-typedef PrimeTable* CreatePrimeTableFunc();
55-
56-PrimeTable* CreateOnTheFlyPrimeTable() {
57- return new OnTheFlyPrimeTable();
58-}
59-
60-template <size_t max_precalculated>
61-PrimeTable* CreatePreCalculatedPrimeTable() {
62- return new PreCalculatedPrimeTable(max_precalculated);
63-}
64-
65-// Inside the test body, fixture constructor, SetUp(), and TearDown() you
66-// can refer to the test parameter by GetParam(). In this case, the test
67-// parameter is a factory function which we call in fixture's SetUp() to
68-// create and store an instance of PrimeTable.
69-class PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> {
70- public:
71- virtual ~PrimeTableTest() { delete table_; }
72- virtual void SetUp() { table_ = (*GetParam())(); }
73- virtual void TearDown() {
74- delete table_;
75- table_ = NULL;
76- }
77-
78- protected:
79- PrimeTable* table_;
80-};
81-
82-TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {
83- EXPECT_FALSE(table_->IsPrime(-5));
84- EXPECT_FALSE(table_->IsPrime(0));
85- EXPECT_FALSE(table_->IsPrime(1));
86- EXPECT_FALSE(table_->IsPrime(4));
87- EXPECT_FALSE(table_->IsPrime(6));
88- EXPECT_FALSE(table_->IsPrime(100));
89-}
90-
91-TEST_P(PrimeTableTest, ReturnsTrueForPrimes) {
92- EXPECT_TRUE(table_->IsPrime(2));
93- EXPECT_TRUE(table_->IsPrime(3));
94- EXPECT_TRUE(table_->IsPrime(5));
95- EXPECT_TRUE(table_->IsPrime(7));
96- EXPECT_TRUE(table_->IsPrime(11));
97- EXPECT_TRUE(table_->IsPrime(131));
98-}
99-
100-TEST_P(PrimeTableTest, CanGetNextPrime) {
101- EXPECT_EQ(2, table_->GetNextPrime(0));
102- EXPECT_EQ(3, table_->GetNextPrime(2));
103- EXPECT_EQ(5, table_->GetNextPrime(3));
104- EXPECT_EQ(7, table_->GetNextPrime(5));
105- EXPECT_EQ(11, table_->GetNextPrime(7));
106- EXPECT_EQ(131, table_->GetNextPrime(128));
107-}
108-
109-// In order to run value-parameterized tests, you need to instantiate them,
110-// or bind them to a list of values which will be used as test parameters.
111-// You can instantiate them in a different translation module, or even
112-// instantiate them several times.
113-//
114-// Here, we instantiate our tests with a list of two PrimeTable object
115-// factory functions:
116-INSTANTIATE_TEST_CASE_P(
117- OnTheFlyAndPreCalculated,
118- PrimeTableTest,
119- Values(&CreateOnTheFlyPrimeTable, &CreatePreCalculatedPrimeTable<1000>));
120-
121-#else
122-
123-// Google Test may not support value-parameterized tests with some
124-// compilers. If we use conditional compilation to compile out all
125-// code referring to the gtest_main library, MSVC linker will not link
126-// that library at all and consequently complain about missing entry
127-// point defined in that library (fatal error LNK1561: entry point
128-// must be defined). This dummy test keeps gtest_main linked in.
129-TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}
130-
131-#endif // GTEST_HAS_PARAM_TEST
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/prime_tables.h (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/prime_tables.h (nonexistent)
@@ -1,123 +0,0 @@
1-// Copyright 2008 Google Inc.
2-// All Rights Reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: wan@google.com (Zhanyong Wan)
31-// Author: vladl@google.com (Vlad Losev)
32-
33-// This provides interface PrimeTable that determines whether a number is a
34-// prime and determines a next prime number. This interface is used
35-// in Google Test samples demonstrating use of parameterized tests.
36-
37-#ifndef GTEST_SAMPLES_PRIME_TABLES_H_
38-#define GTEST_SAMPLES_PRIME_TABLES_H_
39-
40-#include <algorithm>
41-
42-// The prime table interface.
43-class PrimeTable {
44- public:
45- virtual ~PrimeTable() {}
46-
47- // Returns true iff n is a prime number.
48- virtual bool IsPrime(int n) const = 0;
49-
50- // Returns the smallest prime number greater than p; or returns -1
51- // if the next prime is beyond the capacity of the table.
52- virtual int GetNextPrime(int p) const = 0;
53-};
54-
55-// Implementation #1 calculates the primes on-the-fly.
56-class OnTheFlyPrimeTable : public PrimeTable {
57- public:
58- virtual bool IsPrime(int n) const {
59- if (n <= 1) return false;
60-
61- for (int i = 2; i*i <= n; i++) {
62- // n is divisible by an integer other than 1 and itself.
63- if ((n % i) == 0) return false;
64- }
65-
66- return true;
67- }
68-
69- virtual int GetNextPrime(int p) const {
70- for (int n = p + 1; n > 0; n++) {
71- if (IsPrime(n)) return n;
72- }
73-
74- return -1;
75- }
76-};
77-
78-// Implementation #2 pre-calculates the primes and stores the result
79-// in an array.
80-class PreCalculatedPrimeTable : public PrimeTable {
81- public:
82- // 'max' specifies the maximum number the prime table holds.
83- explicit PreCalculatedPrimeTable(int max)
84- : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {
85- CalculatePrimesUpTo(max);
86- }
87- virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; }
88-
89- virtual bool IsPrime(int n) const {
90- return 0 <= n && n < is_prime_size_ && is_prime_[n];
91- }
92-
93- virtual int GetNextPrime(int p) const {
94- for (int n = p + 1; n < is_prime_size_; n++) {
95- if (is_prime_[n]) return n;
96- }
97-
98- return -1;
99- }
100-
101- private:
102- void CalculatePrimesUpTo(int max) {
103- ::std::fill(is_prime_, is_prime_ + is_prime_size_, true);
104- is_prime_[0] = is_prime_[1] = false;
105-
106- for (int i = 2; i <= max; i++) {
107- if (!is_prime_[i]) continue;
108-
109- // Marks all multiples of i (except i itself) as non-prime.
110- for (int j = 2*i; j <= max; j += i) {
111- is_prime_[j] = false;
112- }
113- }
114- }
115-
116- const int is_prime_size_;
117- bool* const is_prime_;
118-
119- // Disables compiler warning "assignment operator could not be generated."
120- void operator=(const PreCalculatedPrimeTable& rhs);
121-};
122-
123-#endif // GTEST_SAMPLES_PRIME_TABLES_H_
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample8_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample8_unittest.cc (nonexistent)
@@ -1,174 +0,0 @@
1-// Copyright 2008 Google Inc.
2-// All Rights Reserved.
3-//
4-// Redistribution and use in source and binary forms, with or without
5-// modification, are permitted provided that the following conditions are
6-// met:
7-//
8-// * Redistributions of source code must retain the above copyright
9-// notice, this list of conditions and the following disclaimer.
10-// * Redistributions in binary form must reproduce the above
11-// copyright notice, this list of conditions and the following disclaimer
12-// in the documentation and/or other materials provided with the
13-// distribution.
14-// * Neither the name of Google Inc. nor the names of its
15-// contributors may be used to endorse or promote products derived from
16-// this software without specific prior written permission.
17-//
18-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-//
30-// Author: vladl@google.com (Vlad Losev)
31-
32-// This sample shows how to test code relying on some global flag variables.
33-// Combine() helps with generating all possible combinations of such flags,
34-// and each test is given one combination as a parameter.
35-
36-// Use class definitions to test from this header.
37-#include "prime_tables.h"
38-
39-//#include "gtest/gtest.h"
40-#include "gtest/iutest_switch.h"
41-
42-#if GTEST_HAS_COMBINE
43-
44-// Suppose we want to introduce a new, improved implementation of PrimeTable
45-// which combines speed of PrecalcPrimeTable and versatility of
46-// OnTheFlyPrimeTable (see prime_tables.h). Inside it instantiates both
47-// PrecalcPrimeTable and OnTheFlyPrimeTable and uses the one that is more
48-// appropriate under the circumstances. But in low memory conditions, it can be
49-// told to instantiate without PrecalcPrimeTable instance at all and use only
50-// OnTheFlyPrimeTable.
51-class HybridPrimeTable : public PrimeTable {
52- public:
53- HybridPrimeTable(bool force_on_the_fly, int max_precalculated)
54- : on_the_fly_impl_(new OnTheFlyPrimeTable),
55- precalc_impl_(force_on_the_fly ? NULL :
56- new PreCalculatedPrimeTable(max_precalculated)),
57- max_precalculated_(max_precalculated) {}
58- virtual ~HybridPrimeTable() {
59- delete on_the_fly_impl_;
60- delete precalc_impl_;
61- }
62-
63- virtual bool IsPrime(int n) const {
64- if (precalc_impl_ != NULL && n < max_precalculated_)
65- return precalc_impl_->IsPrime(n);
66- else
67- return on_the_fly_impl_->IsPrime(n);
68- }
69-
70- virtual int GetNextPrime(int p) const {
71- int next_prime = -1;
72- if (precalc_impl_ != NULL && p < max_precalculated_)
73- next_prime = precalc_impl_->GetNextPrime(p);
74-
75- return next_prime != -1 ? next_prime : on_the_fly_impl_->GetNextPrime(p);
76- }
77-
78- private:
79- OnTheFlyPrimeTable* on_the_fly_impl_;
80- PreCalculatedPrimeTable* precalc_impl_;
81- int max_precalculated_;
82-};
83-
84-using ::testing::TestWithParam;
85-using ::testing::Bool;
86-using ::testing::Values;
87-using ::testing::Combine;
88-
89-// To test all code paths for HybridPrimeTable we must test it with numbers
90-// both within and outside PreCalculatedPrimeTable's capacity and also with
91-// PreCalculatedPrimeTable disabled. We do this by defining fixture which will
92-// accept different combinations of parameters for instantiating a
93-// HybridPrimeTable instance.
94-class PrimeTableTest : public TestWithParam< ::std::tr1::tuple<bool, int> > {
95- protected:
96- virtual void SetUp() {
97- // This can be written as
98- //
99- // bool force_on_the_fly;
100- // int max_precalculated;
101- // tie(force_on_the_fly, max_precalculated) = GetParam();
102- //
103- // once the Google C++ Style Guide allows use of ::std::tr1::tie.
104- //
105- bool force_on_the_fly = ::std::tr1::get<0>(GetParam());
106- int max_precalculated = ::std::tr1::get<1>(GetParam());
107- table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);
108- }
109- virtual void TearDown() {
110- delete table_;
111- table_ = NULL;
112- }
113- HybridPrimeTable* table_;
114-};
115-
116-TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {
117- // Inside the test body, you can refer to the test parameter by GetParam().
118- // In this case, the test parameter is a PrimeTable interface pointer which
119- // we can use directly.
120- // Please note that you can also save it in the fixture's SetUp() method
121- // or constructor and use saved copy in the tests.
122-
123- EXPECT_FALSE(table_->IsPrime(-5));
124- EXPECT_FALSE(table_->IsPrime(0));
125- EXPECT_FALSE(table_->IsPrime(1));
126- EXPECT_FALSE(table_->IsPrime(4));
127- EXPECT_FALSE(table_->IsPrime(6));
128- EXPECT_FALSE(table_->IsPrime(100));
129-}
130-
131-TEST_P(PrimeTableTest, ReturnsTrueForPrimes) {
132- EXPECT_TRUE(table_->IsPrime(2));
133- EXPECT_TRUE(table_->IsPrime(3));
134- EXPECT_TRUE(table_->IsPrime(5));
135- EXPECT_TRUE(table_->IsPrime(7));
136- EXPECT_TRUE(table_->IsPrime(11));
137- EXPECT_TRUE(table_->IsPrime(131));
138-}
139-
140-TEST_P(PrimeTableTest, CanGetNextPrime) {
141- EXPECT_EQ(2, table_->GetNextPrime(0));
142- EXPECT_EQ(3, table_->GetNextPrime(2));
143- EXPECT_EQ(5, table_->GetNextPrime(3));
144- EXPECT_EQ(7, table_->GetNextPrime(5));
145- EXPECT_EQ(11, table_->GetNextPrime(7));
146- EXPECT_EQ(131, table_->GetNextPrime(128));
147-}
148-
149-// In order to run value-parameterized tests, you need to instantiate them,
150-// or bind them to a list of values which will be used as test parameters.
151-// You can instantiate them in a different translation module, or even
152-// instantiate them several times.
153-//
154-// Here, we instantiate our tests with a list of parameters. We must combine
155-// all variations of the boolean flag suppressing PrecalcPrimeTable and some
156-// meaningful values for tests. We choose a small value (1), and a value that
157-// will put some of the tested numbers beyond the capability of the
158-// PrecalcPrimeTable instance and some inside it (10). Combine will produce all
159-// possible combinations.
160-INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
161- PrimeTableTest,
162- Combine(Bool(), Values(1, 10)));
163-
164-#else
165-
166-// Google Test may not support Combine() with some compilers. If we
167-// use conditional compilation to compile out all code referring to
168-// the gtest_main library, MSVC linker will not link that library at
169-// all and consequently complain about missing entry point defined in
170-// that library (fatal error LNK1561: entry point must be
171-// defined). This dummy test keeps gtest_main linked in.
172-TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
173-
174-#endif // GTEST_HAS_COMBINE
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample9_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample9_unittest.cc (nonexistent)
@@ -1,161 +0,0 @@
1-// Copyright 2009 Google Inc. All Rights Reserved.
2-//
3-// Redistribution and use in source and binary forms, with or without
4-// modification, are permitted provided that the following conditions are
5-// met:
6-//
7-// * Redistributions of source code must retain the above copyright
8-// notice, this list of conditions and the following disclaimer.
9-// * Redistributions in binary form must reproduce the above
10-// copyright notice, this list of conditions and the following disclaimer
11-// in the documentation and/or other materials provided with the
12-// distribution.
13-// * Neither the name of Google Inc. nor the names of its
14-// contributors may be used to endorse or promote products derived from
15-// this software without specific prior written permission.
16-//
17-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-//
29-// Author: vladl@google.com (Vlad Losev)
30-
31-// This sample shows how to use Google Test listener API to implement
32-// an alternative console output and how to use the UnitTest reflection API
33-// to enumerate test cases and tests and to inspect their results.
34-
35-#include <stdio.h>
36-
37-//#include "gtest/gtest.h"
38-#include "gtest/iutest_switch.h"
39-
40-using ::testing::EmptyTestEventListener;
41-using ::testing::InitGoogleTest;
42-using ::testing::Test;
43-using ::testing::TestCase;
44-using ::testing::TestEventListeners;
45-using ::testing::TestInfo;
46-using ::testing::TestPartResult;
47-using ::testing::UnitTest;
48-
49-namespace {
50-
51-// Provides alternative output mode which produces minimal amount of
52-// information about tests.
53-class TersePrinter : public EmptyTestEventListener {
54- private:
55- // Called before any test activity starts.
56- virtual void OnTestProgramStart(const UnitTest& /* unit_test */) {}
57-
58- // Called after all test activities have ended.
59- virtual void OnTestProgramEnd(const UnitTest& unit_test) {
60- fprintf(stdout, "TEST %s\n", unit_test.Passed() ? "PASSED" : "FAILED");
61- fflush(stdout);
62- }
63-
64- // Called before a test starts.
65- virtual void OnTestStart(const TestInfo& test_info) {
66- fprintf(stdout,
67- "*** Test %s.%s starting.\n",
68- test_info.test_case_name(),
69- test_info.name());
70- fflush(stdout);
71- }
72-
73- // Called after a failed assertion or a SUCCEED() invocation.
74- virtual void OnTestPartResult(const TestPartResult& test_part_result) {
75- fprintf(stdout,
76- "%s in %s:%d\n%s\n",
77- test_part_result.failed() ? "*** Failure" : "Success",
78- test_part_result.file_name(),
79- test_part_result.line_number(),
80- test_part_result.summary());
81- fflush(stdout);
82- }
83-
84- // Called after a test ends.
85- virtual void OnTestEnd(const TestInfo& test_info) {
86- fprintf(stdout,
87- "*** Test %s.%s ending.\n",
88- test_info.test_case_name(),
89- test_info.name());
90- fflush(stdout);
91- }
92-}; // class TersePrinter
93-
94-TEST(CustomOutputTest, PrintsMessage) {
95- printf("Printing something from the test body...\n");
96-}
97-
98-TEST(CustomOutputTest, Succeeds) {
99- SUCCEED() << "SUCCEED() has been invoked from here";
100-}
101-
102-TEST(CustomOutputTest, Fails) {
103- EXPECT_EQ(1, 2)
104- << "This test fails in order to demonstrate alternative failure messages";
105-}
106-
107-} // namespace
108-
109-int main(int argc, char **argv) {
110- InitGoogleTest(&argc, argv);
111-
112- bool terse_output = false;
113- if (argc > 1 && strcmp(argv[1], "--terse_output") == 0 )
114- terse_output = true;
115- else
116- printf("%s\n", "Run this program with --terse_output to change the way "
117- "it prints its output.");
118-
119- UnitTest& unit_test = *UnitTest::GetInstance();
120-
121- // If we are given the --terse_output command line flag, suppresses the
122- // standard output and attaches own result printer.
123- if (terse_output) {
124- TestEventListeners& listeners = unit_test.listeners();
125-
126- // Removes the default console output listener from the list so it will
127- // not receive events from Google Test and won't print any output. Since
128- // this operation transfers ownership of the listener to the caller we
129- // have to delete it as well.
130- delete listeners.Release(listeners.default_result_printer());
131-
132- // Adds the custom output listener to the list. It will now receive
133- // events from Google Test and print the alternative output. We don't
134- // have to worry about deleting it since Google Test assumes ownership
135- // over it after adding it to the list.
136- listeners.Append(new TersePrinter);
137- }
138- int ret_val = RUN_ALL_TESTS();
139-
140- // This is an example of using the UnitTest reflection API to inspect test
141- // results. Here we discount failures from the tests we expected to fail.
142- int unexpectedly_failed_tests = 0;
143- for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
144- const TestCase& test_case = *unit_test.GetTestCase(i);
145- for (int j = 0; j < test_case.total_test_count(); ++j) {
146- const TestInfo& test_info = *test_case.GetTestInfo(j);
147- // Counts failed tests that were not meant to fail (those without
148- // 'Fails' in the name).
149- if (test_info.result()->Failed() &&
150- strcmp(test_info.name(), "Fails") != 0) {
151- unexpectedly_failed_tests++;
152- }
153- }
154- }
155-
156- // Test that were meant to fail should not affect the test program outcome.
157- if (unexpectedly_failed_tests == 0)
158- ret_val = 0;
159-
160- return ret_val;
161-}
--- trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample10_unittest.cc (revision 273)
+++ trunk/framework/sample/Windows/unittest/src/iutest/gtest/sample10_unittest.cc (nonexistent)
@@ -1,146 +0,0 @@
1-// Copyright 2009 Google Inc. All Rights Reserved.
2-//
3-// Redistribution and use in source and binary forms, with or without
4-// modification, are permitted provided that the following conditions are
5-// met:
6-//
7-// * Redistributions of source code must retain the above copyright
8-// notice, this list of conditions and the following disclaimer.
9-// * Redistributions in binary form must reproduce the above
10-// copyright notice, this list of conditions and the following disclaimer
11-// in the documentation and/or other materials provided with the
12-// distribution.
13-// * Neither the name of Google Inc. nor the names of its
14-// contributors may be used to endorse or promote products derived from
15-// this software without specific prior written permission.
16-//
17-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-//
29-// Author: vladl@google.com (Vlad Losev)
30-
31-// This sample shows how to use Google Test listener API to implement
32-// a primitive leak checker.
33-
34-#include <stdio.h>
35-#include <stdlib.h>
36-
37-//#include "gtest/gtest.h"
38-#include "gtest/iutest_switch.h"
39-
40-using ::testing::EmptyTestEventListener;
41-using ::testing::InitGoogleTest;
42-using ::testing::Test;
43-using ::testing::TestCase;
44-using ::testing::TestEventListeners;
45-using ::testing::TestInfo;
46-using ::testing::TestPartResult;
47-using ::testing::UnitTest;
48-
49-namespace {
50-
51-// We will track memory used by this class.
52-class Water {
53- public:
54- // Normal Water declarations go here.
55-
56- // operator new and operator delete help us control water allocation.
57- void* operator new(size_t allocation_size) {
58- allocated_++;
59- return malloc(allocation_size);
60- }
61-
62- void operator delete(void* block, size_t /* allocation_size */) {
63- allocated_--;
64- free(block);
65- }
66-
67- static int allocated() { return allocated_; }
68-
69- private:
70- static int allocated_;
71-};
72-
73-int Water::allocated_ = 0;
74-
75-// This event listener monitors how many Water objects are created and
76-// destroyed by each test, and reports a failure if a test leaks some Water
77-// objects. It does this by comparing the number of live Water objects at
78-// the beginning of a test and at the end of a test.
79-class LeakChecker : public EmptyTestEventListener {
80- private:
81- // Called before a test starts.
82- virtual void OnTestStart(const TestInfo& /* test_info */) {
83- initially_allocated_ = Water::allocated();
84- }
85-
86- // Called after a test ends.
87- virtual void OnTestEnd(const TestInfo& /* test_info */) {
88- int difference = Water::allocated() - initially_allocated_;
89-
90- // You can generate a failure in any event handler except
91- // OnTestPartResult. Just use an appropriate Google Test assertion to do
92- // it.
93- EXPECT_TRUE(difference <= 0)
94- << "Leaked " << difference << " unit(s) of Water!";
95- }
96-
97- int initially_allocated_;
98-};
99-
100-TEST(ListenersTest, DoesNotLeak) {
101- Water* water = new Water;
102- delete water;
103-}
104-
105-// This should fail when the --check_for_leaks command line flag is
106-// specified.
107-TEST(ListenersTest, LeaksWater) {
108- Water* water = new Water;
109- EXPECT_TRUE(water != NULL);
110-}
111-
112-} // namespace
113-
114-int main(int argc, char **argv) {
115- InitGoogleTest(&argc, argv);
116-
117- bool check_for_leaks = false;
118- if (argc > 1 && strcmp(argv[1], "--check_for_leaks") == 0 )
119- check_for_leaks = true;
120- else
121- printf("%s\n", "Run this program with --check_for_leaks to enable "
122- "custom leak checking in the tests.");
123-
124- // If we are given the --check_for_leaks command line flag, installs the
125- // leak checker.
126- if (check_for_leaks) {
127- TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
128-
129- // Adds the leak checker to the end of the test event listener list,
130- // after the default text output printer and the default XML report
131- // generator.
132- //
133- // The order is important - it ensures that failures generated in the
134- // leak checker's OnTestEnd() method are processed by the text and XML
135- // printers *before* their OnTestEnd() methods are called, such that
136- // they are attributed to the right test. Remember that a listener
137- // receives an OnXyzStart event *after* listeners preceding it in the
138- // list received that event, and receives an OnXyzEnd event *before*
139- // listeners preceding it.
140- //
141- // We don't need to worry about deleting the new listener later, as
142- // Google Test will do it.
143- listeners.Append(new LeakChecker);
144- }
145- return RUN_ALL_TESTS();
146-}
Show on old repository browser