forked from pcb2gcode/pcb2gcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_tests.cpp
37 lines (30 loc) · 1.33 KB
/
common_tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define BOOST_TEST_MODULE common tests
#include <boost/test/unit_test.hpp>
#include "common.hpp"
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
#ifdef BOOST_WINDOWS_API
#define SEP "\\"
#endif
#ifdef BOOST_POSIX_API
#define SEP "/"
#endif
using std::vector;
BOOST_AUTO_TEST_SUITE(common_tests)
// Add more tests by comparing to python's os.path.join
BOOST_AUTO_TEST_CASE(build_filename_tests) {
BOOST_CHECK_EQUAL(build_filename("", ""), "");
BOOST_CHECK_EQUAL(build_filename("a", ""), "a" SEP);
BOOST_CHECK_EQUAL(build_filename("", "b"), "b");
BOOST_CHECK_EQUAL(build_filename("a", "b"), "a" SEP "b");
BOOST_CHECK_EQUAL(build_filename("a" SEP, "b"), "a" SEP "b");
BOOST_CHECK_EQUAL(build_filename("a" SEP, "b"), "a" SEP "b");
BOOST_CHECK_EQUAL(build_filename("a" SEP SEP, "b"), "a" SEP SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP, "b"), SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP "a" SEP, "b"), SEP "a" SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP "a" SEP SEP, "b"), SEP "a" SEP SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP "a" SEP, SEP "b"), SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP "a" SEP, SEP SEP "b"), SEP SEP "b");
BOOST_CHECK_EQUAL(build_filename(SEP "a" SEP, ""), SEP "a" SEP);
BOOST_CHECK_EQUAL(build_filename(SEP "a", ""), SEP "a" SEP);
}
BOOST_AUTO_TEST_SUITE_END()