MCPcopy Create free account
hub / github.com/davisking/dlib / test1_variant

Function test1_variant

dlib/test/vectorstream.cpp:26–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25 template <typename CharType, typename stream>
26 void test1_variant(std::vector<CharType>& buf, stream& s)
27 {
28 for (int i = -1000; i <= 1000; ++i)
29 {
30 char ch = i;
31 s.put(ch);
32 }
33
34 DLIB_TEST(buf.size() == 2001);
35
36 int cnt = -1000;
37 for (unsigned long i = 0; i < buf.size(); ++i)
38 {
39 char ch = cnt;
40 DLIB_TEST((char)buf[i] == ch);
41 ++cnt;
42 }
43
44 for (int i = -1000; i <= 1000; ++i)
45 {
46 DLIB_TEST(s.peek() != EOF);
47 char ch1 = i;
48 char ch2 = s.get();
49 DLIB_TEST(ch1 == ch2);
50 }
51
52 DLIB_TEST(s.peek() == EOF);
53 DLIB_TEST(s.get() == EOF);
54
55 s.clear();
56 s.seekg(6); //Let iostream decide which path to take. In theory it could decide to use any.
57
58 for (int i = -1000+6; i <= 1000; ++i)
59 {
60 DLIB_TEST(s.peek() != EOF);
61 char ch1 = i;
62 char ch2 = s.get();
63 DLIB_TEST(ch1 == ch2);
64 }
65
66 DLIB_TEST(s.peek() == EOF);
67 DLIB_TEST(s.get() == EOF);
68
69 s.clear();
70 s.seekg(6, std::ios_base::beg);
71
72 for (int i = -1000+6; i <= 1000; ++i)
73 {
74 DLIB_TEST(s.peek() != EOF);
75 char ch1 = i;
76 char ch2 = s.get();
77 DLIB_TEST(ch1 == ch2);
78 }
79
80 DLIB_TEST(s.peek() == EOF);
81 DLIB_TEST(s.get() == EOF);
82
83 s.clear();

Callers 1

test1Function · 0.85

Calls 7

seekgMethod · 0.80
readMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
sizeMethod · 0.45
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected