• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

C++ベースのLightweightなHTTPサーバー


Commit MetaInfo

Revision9700784b96894a057792d266dcdb3af2a0ba103c (tree)
Time2012-12-07 23:18:16
AuthorMichio Hirai <smg_ykz@user...>
CommiterMichio Hirai

Log Message

[Refactor] Clarify some other EXPECTATION in ContainerForeach unit tests.
[Function] New introduction ARRAY_LENGTH() macro

Change Summary

Incremental Difference

--- /dev/null
+++ b/inc/mt_array_length.h
@@ -0,0 +1,17 @@
1+
2+#ifndef INC_MT_ARRAY_LENGTH_H_
3+#define INC_MT_ARRAY_LENGTH_H_
4+
5+namespace mt {
6+
7+template <typename T, size_t N>
8+inline unsigned int getArrayLength(const T (&)[N])
9+{
10+ return N;
11+}
12+
13+} // namespace mt
14+
15+#define ARRAY_LENGTH(x) mt::getArrayLength(x)
16+
17+#endif // INC_MT_ARRAY_LENGTH_H_
--- a/inc/test/mt_container_foreach_test.cpp
+++ b/inc/test/mt_container_foreach_test.cpp
@@ -3,6 +3,7 @@
33 #include <string>
44 #include "gtest/gtest.h"
55 #include "mt_container_foreach.h"
6+#include "mt_array_length.h"
67
78 TEST(ContainerForeachTest, std_vector_container_test)
89 {
@@ -113,35 +114,22 @@ TEST(ContainerForeachConstTest, fixed_array_test)
113114 std::string fixed_array[10];
114115
115116 const char* string_array[] = {
116- "hello",
117- "world",
118- "3",
119- "4",
120- "5",
121- "6",
122- "good",
123- "bye",
124- "cruel",
125- "world"
117+ "hello", "world", "3", "4", "5", "6",
118+ "good", "bye", "cruel", "world"
126119 };
127120
128-
129121 unsigned int count = 0;
130122 CONTAINER_FOREACH(std::string& item, fixed_array) {
131123 item = string_array[count];
132124 ++count;
133125 }
134-
126+ EXPECT_EQ(ARRAY_LENGTH(fixed_array), count);
135127
136128 count = 0;
137129 CONTAINER_FOREACH_CONST(const std::string& item, fixed_array) {
138130 EXPECT_STREQ(item.c_str(), string_array[count]);
139131 ++count;
140132 }
141-
142-
143-
133+ EXPECT_EQ(ARRAY_LENGTH(fixed_array), count);
144134 }
145135
146-
147-