onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame] | 1 | //#define DOCTEST_CONFIG_DISABLE
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 2 |
|
onqtam | cae7312 | 2016-04-29 14:57:23 +0300 | [diff] [blame] | 3 | #include "doctest.h"
|
onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame] | 4 | #define DOCTEST_CONFIG_IMPLEMENT
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 5 | #include "doctest.h"
|
| 6 |
|
| 7 | #include <cstdio>
|
onqtam | cae7312 | 2016-04-29 14:57:23 +0300 | [diff] [blame] | 8 | #include <cstdlib>
|
onqtam | 4286919 | 2016-05-15 19:06:24 +0300 | [diff] [blame] | 9 | #include <vector>
|
onqtam | 1d14506 | 2016-05-18 12:52:45 +0300 | [diff] [blame] | 10 | //#include <ostream>
|
onqtam | 4286919 | 2016-05-15 19:06:24 +0300 | [diff] [blame] | 11 |
|
| 12 | //template <typename T>
|
| 13 | //std::ostream& operator<<(std::ostream& s, const std::vector<T>& in) {
|
| 14 | // s << "[";
|
| 15 | // for(size_t i = 0; i < in.size(); ++i)
|
| 16 | // if(i < in.size() - 1)
|
| 17 | // s << in[i] << ", ";
|
| 18 | // else
|
| 19 | // s << in[i];
|
| 20 | // s << "]";
|
| 21 | // return s;
|
| 22 | //}
|
onqtam | e08cd40 | 2016-05-16 19:18:25 +0300 | [diff] [blame] | 23 |
|
onqtam | 1d14506 | 2016-05-18 12:52:45 +0300 | [diff] [blame] | 24 | #include <algorithm>
|
| 25 | #include <limits>
|
| 26 | #include <cmath>
|
| 27 |
|
onqtam | e08cd40 | 2016-05-16 19:18:25 +0300 | [diff] [blame] | 28 |
|
onqtam | e08cd40 | 2016-05-16 19:18:25 +0300 | [diff] [blame] | 29 |
|
onqtam | fd527f9 | 2016-05-19 15:45:39 +0300 | [diff] [blame] | 30 | SCENARIO("[math]vectors can be sized and resized") {
|
onqtam | e08cd40 | 2016-05-16 19:18:25 +0300 | [diff] [blame] | 31 |
|
onqtam | fd527f9 | 2016-05-19 15:45:39 +0300 | [diff] [blame] | 32 | GIVEN("A vector with some items") {
|
| 33 | std::vector<int> v(5);
|
| 34 |
|
| 35 | REQUIRE(v.size() == 5u);
|
| 36 | REQUIRE(v.capacity() >= 5u);
|
| 37 |
|
| 38 | WHEN("the size is increased") {
|
| 39 | v.resize(10);
|
| 40 |
|
| 41 | THEN("the size and capacity change") {
|
| 42 | REQUIRE(v.size() == 10u);
|
| 43 | REQUIRE(v.capacity() >= 10u);
|
| 44 | }
|
| 45 | }
|
| 46 | WHEN("the size is reduced") {
|
| 47 | v.resize(0);
|
| 48 |
|
| 49 | THEN("the size changes but not capacity") {
|
| 50 | REQUIRE(v.size() == 0u);
|
| 51 | REQUIRE(v.capacity() >= 5u);
|
| 52 | }
|
| 53 | }
|
| 54 | WHEN("more capacity is reserved") {
|
| 55 | v.reserve(10);
|
| 56 |
|
| 57 | THEN("the capacity changes but not the size") {
|
| 58 | REQUIRE(v.size() == 5u);
|
| 59 | REQUIRE(v.capacity() >= 10u);
|
| 60 | }
|
| 61 | }
|
| 62 | WHEN("less capacity is reserved") {
|
| 63 | v.reserve(0);
|
| 64 |
|
| 65 | THEN("neither size nor capacity are changed") {
|
| 66 | REQUIRE(v.size() == 5u);
|
| 67 | REQUIRE(v.capacity() >= 5u);
|
| 68 | }
|
| 69 | }
|
| 70 | }
|
onqtam | e08cd40 | 2016-05-16 19:18:25 +0300 | [diff] [blame] | 71 | }
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 72 |
|
onqtam | fd527f9 | 2016-05-19 15:45:39 +0300 | [diff] [blame] | 73 | //TEST_CASE("zzz") {
|
| 74 | // //CHECK(std::string("OMG2") == std::string("OMG"));
|
| 75 | //
|
| 76 | // std::vector<int> vec1;
|
| 77 | // vec1.push_back(1);
|
| 78 | // vec1.push_back(2);
|
| 79 | // vec1.push_back(3);
|
| 80 | //
|
| 81 | // std::vector<int> vec2;
|
| 82 | // vec2.push_back(1);
|
| 83 | // vec2.push_back(2);
|
| 84 | // vec2.push_back(4);
|
| 85 | //
|
| 86 | // //CHECK(vec1 == vec2);
|
| 87 | //}
|
| 88 |
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 89 | int main(int argc, char** argv) {
|
| 90 | // initialize
|
| 91 | doctest::Context context(argc, argv);
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 92 |
|
| 93 | // overrides
|
| 94 | context.setOption("dt-case-sensitive", true);
|
onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame] | 95 | context.setOption("no-breaks", true);
|
onqtam | 7049f40 | 2016-05-12 23:58:59 +0300 | [diff] [blame] | 96 | //context.setOption("success", true);
|
onqtam | ad0d6d2 | 2016-05-11 17:46:02 +0300 | [diff] [blame] | 97 | //context.setOption("no-throw", true);
|
onqtam | 0cea9bc | 2016-04-27 12:59:08 +0300 | [diff] [blame] | 98 | //context.setOption("dt-no-colors", true);
|
onqtam | fd527f9 | 2016-05-19 15:45:39 +0300 | [diff] [blame] | 99 | //context.addFilter("test-case", "zzz");
|
onqtam | 3af136c | 2016-05-12 18:05:18 +0300 | [diff] [blame] | 100 | //context.setOption("abort-after", 1);
|
onqtam | 76c1364 | 2016-05-11 17:30:29 +0300 | [diff] [blame] | 101 | //context.addFilter("suite", "randomness");
|
| 102 | //context.setOption("sort", "rand");
|
| 103 | //context.setOption("rand-seed", 435);
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 104 |
|
| 105 | // run
|
onqtam | b91b68e | 2016-05-04 20:16:19 +0300 | [diff] [blame] | 106 | int res = context.run();
|
| 107 |
|
| 108 | if(context.shouldExit())
|
| 109 | return res;
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 110 |
|
| 111 | #if defined(WITH_PAUSE)
|
| 112 | system("pause");
|
onqtam | 8ccce3b | 2016-04-20 20:46:05 +0300 | [diff] [blame] | 113 | #endif // WITH_PAUSE
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 114 |
|
| 115 | return res;
|
| 116 | }
|