etrobocon2018 feat.KatLab  770af34cce41ae9c30c41303275e1add2daae0c3 (with uncommitted changes)
 全て クラス 名前空間 ファイル 関数 変数 列挙型 列挙値 フレンド マクロ定義 ページ
AIAnswerArrayTest.cpp
[詳解]
1 
6 #include "AIAnswerArray.h"
7 #include <gtest/gtest.h>
8 
9 namespace etrobocon2018_test {
10  TEST(AIAnswerArrayTest, construct)
11  {
13  }
14 
15  TEST(AIAnswerArrayTest, constructSpecifiedSize)
16  {
18  }
19 
20  TEST(AIAnswerArrayTest, constructSpecifiedType)
21  {
24  }
25 
26  TEST(AIAnswerArrayTest, sizeTest)
27  {
29  ASSERT_EQ(6, array.size());
30 
32  ASSERT_EQ(1, list.size());
33  }
34 
35  TEST(AIAnswerArrayTest, positionTest)
36  {
38  ASSERT_EQ(0, array.position());
39 
40  array.push_back(1);
41  ASSERT_EQ(1, array.position());
42 
43  array.push_back(20);
44  ASSERT_EQ(2, array.position());
45  }
46 
47  TEST(AIAnswerArrayTest, atTest)
48  {
50  ASSERT_EQ(0, array.at(0));
51 
52  array.push_back(100);
53  ASSERT_EQ(100, array.at(0));
54 
55  array.push_back(200);
56  ASSERT_EQ(200, array.at(1));
57  }
58 
59  TEST(AIAnswerArrayTest, atTestDouble)
60  {
62  ASSERT_DOUBLE_EQ(0.0, array.at(0));
63 
64  array.push_back(1.2);
65  ASSERT_DOUBLE_EQ(1.2, array.at(0));
66  }
67 
68  TEST(AIAnswerArrayTest, operatorTest)
69  {
71  ASSERT_EQ(0, array[0]);
72 
73  array.push_back(100);
74  ASSERT_EQ(100, array[0]);
75 
76  array.push_back(200);
77  ASSERT_EQ(200, array[1]);
78  }
79 
80  TEST(AIAnswerArrayTest, castTest)
81  {
83  ASSERT_EQ(0, array.cast(0));
84  }
85 
86  TEST(AIAnswerArrayTest, probsTest)
87  {
89  array.push_back({1, 0, 1, 1, 0, 1});
90  array.handwriting();
91 
92  ASSERT_EQ(1.0, array.probs[2]);
93  }
94 
95 
96  TEST(AIAnswerArrayTest, handwritingTest)
97  {
99  array.push_back({0, 0, 1, 1, 1, 1});
100 
101  ASSERT_EQ(0, array.handwriting());
102 
103  AI_Answer::array<int> array1;
104  array1.push_back({0, 0, 0, 1, 0, 1});
105  ASSERT_EQ(1, array1.handwriting());
106 
107  AI_Answer::array<int> array2;
108  array2.push_back({1, 0, 1, 1, 0, 1});
109  ASSERT_EQ(2, array2.handwriting());
110 
111  AI_Answer::array<int> array3;
112  array3.push_back({1, 0, 0, 1, 1, 1});
113  ASSERT_EQ(3, array3.handwriting());
114 
115  AI_Answer::array<int> array4;
116  array4.push_back({1, 1, 1, 0, 1, 1});
117  ASSERT_EQ(4, array4.handwriting());
118 
119  AI_Answer::array<int> array5;
120  array5.push_back({1, 1, 0, 1, 1, 1});
121  ASSERT_EQ(5, array5.handwriting());
122 
123  AI_Answer::array<int> array6;
124  array6.push_back({1, 1, 1, 1, 1, 1});
125  ASSERT_EQ(6, array6.handwriting());
126 
127  AI_Answer::array<int> array7;
128  array7.push_back({1, 0, 0, 1, 0, 1});
129  ASSERT_EQ(7, array7.handwriting());
130  }
131 
132 
133 }
constexpr T at(const std::uint8_t i) noexcept
Definition: AIAnswerArray.h:50
constexpr T cast(int i)
std::array< float, 8 > probs
Definition: AIAnswerArray.h:22
std::int8_t handwriting() noexcept
Definition: AIAnswerArray.h:55
TEST(AIAnswerArrayTest, construct)
constexpr std::uint8_t position() noexcept
配列の要素を指し示すポインタを返す
Definition: AIAnswerArray.h:28
AIアンサーで使う配列
constexpr std::uint8_t size() noexcept
配列のサイズを返す
Definition: AIAnswerArray.h:25
void push_back(const T &value) noexcept
配列の要素を入れる
Definition: AIAnswerArray.h:38