Skip to content

Commit

Permalink
Add source location test case
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohan.xu@sectrend.com.cn committed Nov 21, 2024
1 parent 8d97814 commit b09b75e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions cplusplus/stl/05_va_args.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "utils/test.hpp"

#include <cstdarg>

//===========================================================
void out_args(const char *msg, ...) {
va_list args;
printf("%s\n", msg);

va_start(args, msg);
char *curr = NULL;
while (NULL != (curr = va_arg(args, char *))) {
printf("%s\n", curr);
}
va_end(args);
}

void test_va_args() { out_args("hello", "world", "!"); }

//===========================================================
void test() { TEST(test_va_args); }

//===========================================================
int main() { test(); }
29 changes: 29 additions & 0 deletions cplusplus/stl/06_source_loaction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "utils/test.hpp"
// #include <source_location>
#include <experimental/source_location>

//=====================================================
void test_source_location_1(const std::experimental::source_location src_loc =
std::experimental::source_location::current()) {
out("filename: ", src_loc.file_name());
out("function name: ", src_loc.function_name());
out("line: ", src_loc.line());
out("column: ", src_loc.column());
}

void test_source_location_2() {
auto src_loc = std::experimental::source_location::current();
out("filename: ", src_loc.file_name());
out("function name: ", src_loc.function_name());
out("line: ", src_loc.line());
out("column: ", src_loc.column());
}

//=====================================================
void test() {
TEST(test_source_location_1);
TEST(test_source_location_2);
}

//=====================================================
int main() { test(); }
18 changes: 18 additions & 0 deletions cplusplus/stl/07_compare.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "utils/test.hpp"

#include <experimental/compare>

/= == == == == == == == == == == == == == == == == == == == == == == == == == ==
void test_compare(){

}

/= == == == == == == == == == == == == == == == == == == == == == == == == == ==
void test(){
// todo
}

/= == == == == == == == == == == == == == == == == == == == == == == == == == ==
int main() {
test();
}
File renamed without changes.
3 changes: 0 additions & 3 deletions cplusplus/stl/test.cpp

This file was deleted.

0 comments on commit b09b75e

Please sign in to comment.