List of commits:
Subject Hash Author Date (UTC)
asserter update 390196551ae20bd734b441c32a4e20aded4e6394 mucbuc 2020-06-27 15:13:06
silent ab22b60ab194abcf99f9f215239434ef8a1d6121 Ubuntu 2020-04-06 04:38:32
rename 5359c6029c1080d29887e88127fb37f8918d8066 Ubuntu 2020-04-06 04:13:04
dont run if build fails 4986cf7e97d2019b61cae2970030ebb3c1a51168 Ubuntu 2020-04-05 23:10:42
test56 64c03cd6b03d61600e12a76c6ab623f7567b7ed8 Ubuntu 2020-04-01 05:11:28
test10 0596a0ef4052813eb8b2431096d5ff2f969f3ec9 Ubuntu 2020-04-01 05:03:21
test9 648cfb34e18d9ef6e8f9f33088b601aeeaed47b9 Ubuntu 2020-04-01 04:59:38
test8 c7d23043bad421e9ee06269567d97e3f894b58bb Ubuntu 2020-04-01 04:55:36
test6 cb9441b6be2b8175bd0d338decddb1eef82a15a6 Ubuntu 2020-04-01 04:52:26
test5] bcfbe9a0238a8ab5046211b9302f8fe71d1fc6af Ubuntu 2020-04-01 04:50:04
test4 01789d82fd44bb05952a4b0f51314b3d6005d4db Ubuntu 2020-04-01 04:31:30
test3 12f4cdd3d957d06a0810227df38e319e7e5aaa7e Ubuntu 2020-04-01 04:29:32
test2 25199a1879f59b73c3545817dcc38094c8794c3c Ubuntu 2020-04-01 04:06:40
test 71b0bb453140d43fe2019d98349ba9abe2e2b0b5 Ubuntu 2020-04-01 04:01:32
format 07fea6d901a0a1b39e113ed2eab2521bb84e4dcf Ubuntu 2020-03-31 04:36:04
yml support a0aca84f236cf2c0ac729030c3031999419530e2 Ubuntu 2020-03-30 19:20:30
prettier c0a36395356a8e6b165785b5e2dd5486fa22206d Ubuntu 2020-03-30 04:06:19
fix shit 4e786cec2b361164d67318fb9bc4d3e16b5e3156 Ubuntu 2020-03-30 02:55:58
color output 79515e592fad2cee9a985e0050969f6901451e93 Ubuntu 2020-03-30 02:42:46
output 6eec625ecbd51533330d2a1b618d28a433ae1ee4 Ubuntu 2020-03-30 02:37:25
Commit 390196551ae20bd734b441c32a4e20aded4e6394 - asserter update
Author: mucbuc
Author date (UTC): 2020-06-27 15:13
Committer name: mucbuc
Committer date (UTC): 2020-06-27 15:13
Parent(s): ab22b60ab194abcf99f9f215239434ef8a1d6121
Signing key:
Tree: 72373708167326d562f05fa18881fabd319ad23e
File Lines added Lines deleted
asserter/def.yml 0 8
asserter/package.json 3 2
asserter/src/archiver.cpp 46 49
asserter/src/archiver.h 16 17
asserter/src/asserter.cpp 30 41
asserter/src/asserter.h 66 68
asserter/src/asserter.hxx 6 3
asserter/test/src/check_assert.cpp 7 6
File asserter/def.yml deleted (index 4900687..0000000)
1 ---
2 sources:
3 - src/archiver.cpp
4 - src/archiver.h
5 - src/asserter.cpp
6 - src/asserter.h
7 - src/asserter.hxx
8 - src/test.h
File asserter/package.json changed (mode: 100644) (index ef870de..f17ce19)
1 1 { {
2 2 "scripts": { "scripts": {
3 "test": "tape test/test.js"
3 "test": "tape test/test.js",
4 "format": "clang-format -i --style=Webkit src/*.h src/*.hxx src/*.cpp test/src/*.cpp"
4 5 }, },
5 6 "dependencies": { "dependencies": {
6 7 "expector": "*", "expector": "*",
7 8 "tape": "*" "tape": "*"
8 9 } }
9 }
10 }
File asserter/src/archiver.cpp changed (mode: 100644) (index 2f6e4e1..e08bf26)
7 7
8 8 using namespace std; using namespace std;
9 9
10 namespace private_assert
10 namespace private_assert {
11 archiver& archiver::instance()
11 12 { {
12 archiver & archiver::instance()
13 {
14 static archiver local;
15 return local;
16 }
13 static archiver local;
14 return local;
15 }
17 16
18 archiver::~archiver()
19 {
20 fstream out( "result.json", fstream::out );
17 archiver::~archiver()
18 {
19 fstream out("result.json", fstream::out);
20
21 out << "{\n";
22 out << "\"passed\": " << m_passed;
21 23
22 out << "{\n";
23 out << "\"passed\": " << m_passed;
24 if (m_failed.begin() != m_failed.end()) {
25 out << "," << endl;
24 26
25 if (m_failed.begin() != m_failed.end())
26 {
27 out << "," << endl;
27 auto i(m_failed.begin());
28 out << "\"failed\": [" << endl
29 << *(i++) << endl;
30 while (i != m_failed.end())
31 out << ", " << *(i++) << endl;
32 out << "]" << endl;
33 } else {
34 out << endl;
35 }
36 out << "}\n";
37 }
28 38
29 auto i( m_failed.begin() );
30 out << "\"failed\": [" << endl << *(i++) << endl;
31 while (i != m_failed.end())
32 out << ", " << *(i++) << endl;
33 out << "]" << endl;
34 }
35 else {
36 out << endl;
37 }
38 out << "}\n";
39 }
39 void archiver::pass()
40 {
41 ++m_passed;
42 }
40 43
41 void archiver::pass()
42 {
43 ++m_passed;
44 }
44 void archiver::fail(
45 const char* file,
46 int line,
47 const char* function,
48 const char* message)
49 {
45 50
46 void archiver::fail(
47 const char * file,
48 int line,
49 const char * function,
50 const char * message )
51 {
52
53 stringstream entry;
54 entry << "{" << endl;
51 stringstream entry;
52 entry << "{" << endl;
55 53
56 if (strlen(message))
57 {
58 entry << "\"message\":\"" << message << "\"," << endl;
59 }
60 entry << "\"file\":\"" << file << "\"," << endl;
61 entry << "\"function\":\"" << function << "\"," << endl;
62 entry << "\"line\":" << line << endl;
63 entry << "}" << endl;
54 if (strlen(message)) {
55 entry << "\"message\":\"" << message << "\"," << endl;
56 }
57 entry << "\"file\":\"" << file << "\"," << endl;
58 entry << "\"function\":\"" << function << "\"," << endl;
59 entry << "\"line\":" << line << endl;
60 entry << "}" << endl;
64 61
65 m_failed.push_back( entry.str() );
66 }
67 } // private_assert
62 m_failed.push_back(entry.str());
63 }
64 } // private_assert
File asserter/src/archiver.h changed (mode: 100644) (index 3efe692..8292bfe)
2 2 #define ARCHIVER_INCLUDE_GUARD_03K9027KSIQ #define ARCHIVER_INCLUDE_GUARD_03K9027KSIQ
3 3
4 4 #include <iostream> #include <iostream>
5 #include <vector>
6 5 #include <string> #include <string>
6 #include <vector>
7
8 namespace private_assert {
9 struct archiver {
10 static archiver& instance();
7 11
8 namespace private_assert
9 {
10 struct archiver
11 {
12 static archiver & instance();
12 ~archiver();
13 13
14 ~archiver();
14 void pass();
15 void fail(
16 const char*,
17 int,
18 const char* function,
19 const char* = "");
15 20
16 void pass();
17 void fail(
18 const char *,
19 int,
20 const char * function,
21 const char * = "");
22 private:
23 std::size_t m_passed = 0;
24 std::vector< std::string > m_failed;
25 };
21 private:
22 std::size_t m_passed = 0;
23 std::vector<std::string> m_failed;
24 };
26 25 } }
27 26
28 27 #endif // ARCHIVER_INCLUDE_GUARD_03K9027KSIQ #endif // ARCHIVER_INCLUDE_GUARD_03K9027KSIQ
File asserter/src/asserter.cpp changed (mode: 100644 -> 100755) (index 13ac8b7..fb5c2e1)
3 3 #include "archiver.h" #include "archiver.h"
4 4 #include "asserter.h" #include "asserter.h"
5 5
6 #undef SMART_ASSERT_A
6 #undef SMART_ASSERT_A
7 7 #undef SMART_ASSERT_B #undef SMART_ASSERT_B
8 8 #undef SMART_ASSERT_OP #undef SMART_ASSERT_OP
9 9 #undef SMART_ASSERT #undef SMART_ASSERT
 
13 13 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
14 14 // asserter_t // asserter_t
15 15 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
16 asserter_t::asserter_t(bool value)
17 : SMART_ASSERT_A( * this )
18 , SMART_ASSERT_B( * this )
19 , m_value( value )
20 {}
16 asserter_t::asserter_t(bool value)
17 : SMART_ASSERT_A(*this)
18 , SMART_ASSERT_B(*this)
19 , m_value(value)
20 {
21 }
21 22
22 23 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
23 24 bool asserter_t::pass() const bool asserter_t::pass() const
24 {
25 return m_value;
25 {
26 return m_value;
26 27 } }
27 28
28 29 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
29 const asserter_t & asserter_t::print_message(
30 const char * file,
31 int line,
32 const char * function,
33 const char * message) const
30 const asserter_t& asserter_t::print_message(
31 const char* file,
32 int line,
33 const char* function,
34 const char* message) const
34 35 { {
35 static const char * code_red( "\x1b[31m" );
36 static const char * code_reset( "\x1b[39;49m" );
36 static const char* code_red("\x1b[31m");
37 static const char* code_reset("\x1b[39;49m");
37 38
38 39 using namespace std; using namespace std;
39 40
40 if (pass())
41 {
42 cout << "assertion passed: " << message << endl
43 << "file: " << file << endl
44 << "line: " << line << endl
45 << "function: " << function << endl;
46 }
47 else
48 {
41 if (!pass()) {
49 42 cout << code_red cout << code_red
50 << "assertion failed: " << message << endl
51 << "file: " << file << endl
52 << "line: " << line << endl
43 << "assertion failed: " << message << endl
44 << "file: " << file << endl
45 << "line: " << line << endl
53 46 << "function: " << function << "function: " << function
54 47 << code_reset << endl; << code_reset << endl;
55 48 } }
56 return * this;
49 return *this;
57 50 } }
58 51
59 52 ///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
60 const asserter_t & asserter_t::archive_result(
61 const char * file,
62 int line,
63 const char * function,
64 const char * message ) const
53 const asserter_t& asserter_t::archive_result(
54 const char* file,
55 int line,
56 const char* function,
57 const char* message) const
65 58 { {
66 auto & a( private_assert::archiver::instance() );
59 auto& a(private_assert::archiver::instance());
67 60 if (pass()) if (pass())
68 61 a.pass(); a.pass();
69 else
70 a.fail( file, line, function, message );
71 return * this;
62 else
63 a.fail(file, line, function, message);
64 return *this;
72 65 } }
73 66
74 67 #endif // NDEBUG #endif // NDEBUG
75
76
77
78
File asserter/src/asserter.h changed (mode: 100644 -> 100755) (index de41d80..0f8a8de)
11 11
12 12 #ifdef NDEBUG #ifdef NDEBUG
13 13
14 #define ASSERT( expr ) \
15 if (false); \
16 else \
17 struct local_t \
18 { \
19 local_t( const asserter_t & ) {} \
20 } local_obj = asserter_t(false)
21
22 // asserter_t
23 class asserter_t
24 {
25 public:
26 template<class T> const asserter_t operator()(const T &) const { return asserter_t(); }
27 };
14 #define ASSERT(expr) \
15 if (false) \
16 ; \
17 else \
18 struct local_t { \
19 local_t(const asserter_t&) {} \
20 } local_obj = asserter_t(false)
21
22 // asserter_t
23 class asserter_t {
24 public:
25 template <class T>
26 const asserter_t operator()(const T&) const { return asserter_t(); }
27 };
28 28
29 29 #else #else
30 30
31 #define SMART_ASSERT_A(x) SMART_ASSERT_OP(x, B)
32 #define SMART_ASSERT_B(x) SMART_ASSERT_OP(x, A)
33 #define SMART_ASSERT_OP(x, next) SMART_ASSERT_A.print_current_val((x), #x).SMART_ASSERT_ ## next
34
35 #ifndef TARGET_TEST
36 #define TARGET_TEST 0
37 #endif
38
39 #define ASSERT( expr ) \
40 if (!TARGET_TEST && (expr)); \
41 else \
42 struct local_t \
43 { \
44 local_t( const asserter_t & o ) \
45 { \
46 if( !(o.pass()) ) \
47 assert(false); \
48 } \
49 } \
50 local_obj = \
51 asserter_t( expr ) \
52 .print_message( __FILE__, __LINE__, __FUNCTION__, #expr ) \
53 .archive_result( __FILE__, __LINE__, __FUNCTION__, #expr ) \
54 .SMART_ASSERT_A
55
56 // asserter_t
57 struct asserter_t final
58 {
59 asserter_t(bool);
60
61 bool pass() const;
62
63 const asserter_t & print_message(
64 const char * file,
65 int line,
66 const char * function,
67 const char * = "" ) const;
68
69 const asserter_t & archive_result(
70 const char * file,
71 int line,
72 const char * function,
73 const char * = "" ) const;
74
75 template<class U> const asserter_t & print_current_val(const U &, const char*) const;
76
77 asserter_t & SMART_ASSERT_A;
78 asserter_t & SMART_ASSERT_B;
79
80 private:
81 const bool m_value;
82 };
83
84 #include "asserter.hxx"
31 #define SMART_ASSERT_A(x) SMART_ASSERT_OP(x, B)
32 #define SMART_ASSERT_B(x) SMART_ASSERT_OP(x, A)
33 #define SMART_ASSERT_OP(x, next) SMART_ASSERT_A.print_current_val((x), #x).SMART_ASSERT_##next
34
35 #ifndef TARGET_TEST
36 #define TARGET_TEST 0
37 #endif
38
39 #define ASSERT(expr) \
40 if (!TARGET_TEST && (expr)) \
41 ; \
42 else \
43 struct local_t { \
44 local_t(const asserter_t& o) \
45 { \
46 if (!(o.pass())) \
47 assert(false); \
48 } \
49 } local_obj = asserter_t(expr) \
50 .print_message(__FILE__, __LINE__, __FUNCTION__, #expr) \
51 .archive_result(__FILE__, __LINE__, __FUNCTION__, #expr) \
52 .SMART_ASSERT_A
53
54 // asserter_t
55 struct asserter_t final {
56 asserter_t(bool);
57
58 bool pass() const;
59
60 const asserter_t& print_message(
61 const char* file,
62 int line,
63 const char* function,
64 const char* = "") const;
65
66 const asserter_t& archive_result(
67 const char* file,
68 int line,
69 const char* function,
70 const char* = "") const;
71
72 template <class U>
73 const asserter_t& print_current_val(const U&, const char*) const;
74
75 asserter_t& SMART_ASSERT_A;
76 asserter_t& SMART_ASSERT_B;
77
78 private:
79 const bool m_value;
80 };
81
82 #include "asserter.hxx"
85 83
86 84 #endif // NDEBUG #endif // NDEBUG
87 85
File asserter/src/asserter.hxx changed (mode: 100644 -> 100755) (index c6a05f5..3ad5288)
1 1 // ///////////////////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////////////////////
2 2 // // asserter_t // // asserter_t
3 3 // ///////////////////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////////////////////
4 template<class U> const asserter_t & asserter_t::print_current_val(const U & value, const char * message) const
4 template <class U>
5 const asserter_t& asserter_t::print_current_val(const U& value, const char* message) const
5 6 { {
6 std::cout << message << ": " << value << std::endl;
7 return * this;
7 if (!pass()) {
8 std::cout << message << ": " << value << std::endl;
9 }
10 return *this;
8 11 } }
File asserter/test/src/check_assert.cpp changed (mode: 100644) (index f56fbc2..d9ab4da)
1 #include <exception>
1 2 #include <string> #include <string>
2 #include <exception>
3 3
4 4 #include <tmp/src/test.h> #include <tmp/src/test.h>
5 5
6 int main(int argc, const char * argv[])
6 int main(int argc, const char* argv[])
7 7 { {
8 using namespace std;
9 string a( "hello" );
8 using namespace std;
9 string a("hello");
10 10
11 ASSERT( !a.empty() )( a )( a.size() );
11 ASSERT(!a.empty())
12 (a)(a.size());
12 13
13 return 0;
14 return 0;
14 15 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mucbuc/ccargs

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mucbuc/ccargs

Clone this repository using git:
git clone git://git.rocketgit.com/user/mucbuc/ccargs

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main