OpenVPN 3 Core Library
Loading...
Searching...
No Matches
test_streq.cpp
Go to the documentation of this file.
1
#include "
test_common.hpp
"
2
#include <iostream>
3
4
#include <
openvpn/common/size.hpp
>
5
#include <
openvpn/common/exception.hpp
>
6
7
#include <
openvpn/common/strneq.hpp
>
8
9
using namespace
openvpn
;
10
11
void
test
(
const
std::string &s1,
const
std::string &s2,
const
bool
should_eq)
12
{
13
const
bool
neq =
crypto::str_neq
(s1, s2);
14
// OPENVPN_LOG("'" << s1 << "' cmp '" << s2 << "' " << (neq ? "NEQ" : "EQ"));
15
ASSERT_NE(neq, should_eq);
16
}
17
18
TEST
(misc, streq)
19
{
20
test
(
""
,
""
,
true
);
21
test
(
"x"
,
""
,
false
);
22
test
(
""
,
"x"
,
false
);
23
test
(
"foo"
,
"foo"
,
true
);
24
test
(
"foobar"
,
"foo"
,
false
);
25
test
(
"foo"
,
"foobar"
,
false
);
26
}
27
28
void
test_timing
()
29
{
30
size_t
count = 0;
31
for
(
size_t
i = 0; i < 1000000000; ++i)
32
count +=
crypto::str_neq
(
"foobarxxx"
,
"foobar"
);
33
OPENVPN_LOG
(count);
34
}
exception.hpp
OPENVPN_LOG
#define OPENVPN_LOG(args)
Definition
logdatetime.hpp:23
openvpn::crypto::str_neq
bool str_neq(const char *s1, const char *s2)
Definition
strneq.hpp:25
openvpn
Definition
ovpncli.cpp:97
size.hpp
strneq.hpp
test_common.hpp
test
void test()
Definition
test_rc.cpp:80
TEST
TEST(misc, streq)
Definition
test_streq.cpp:18
test_timing
void test_timing()
Definition
test_streq.cpp:28
test
unittests
test_streq.cpp
Generated by
1.9.8