Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brryan committed Nov 8, 2024
1 parent 9737637 commit fde222a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,7 @@ add_subdirectory(external/jaybenne)
# Add artemis
message("\nConfiguring src")
add_subdirectory(src)

# Add testing
message("\nConfiguring tst")
add_subdirectory(tst)
1 change: 1 addition & 0 deletions tst/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(unit)
32 changes: 32 additions & 0 deletions tst/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(unit_tests)

# Set the source files
set(SRC_FILES
main.cpp
# List the test headers (they are included in main.cpp)
#test_function1.h
#test_function2.h
# Add more test headers here
)

# Include directories from your main codebase
include_directories(
${PROJECT_SOURCE_DIR}/../../src # Adjust the path as needed
# Include other directories if necessary
)

# Find and include any required packages
# find_package(PackageName REQUIRED)
# include_directories(${PackageName_INCLUDE_DIRS})

# Add the executable
add_executable(unit_test ${SRC_FILES})

# Link against your main codebase library (if available)
# add_subdirectory(${PROJECT_SOURCE_DIR}/../../src ${CMAKE_BINARY_DIR}/src)
# target_link_libraries(unit_test artemis_library_name)

# If your codebase is not a library, you might need to include source files directly
# target_sources(unit_test PRIVATE ${PROJECT_SOURCE_DIR}/../../src/your_source.cpp)
53 changes: 53 additions & 0 deletions tst/unit/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//========================================================================================
// (C) (or copyright) 2023-2024. Triad National Security, LLC. All rights reserved.
//
// This program was produced under U.S. Government contract 89233218CNA000001 for Los
// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC
// for the U.S. Department of Energy/National Nuclear Security Administration. All rights
// in the program are reserved by Triad National Security, LLC, and the U.S. Department
// of Energy/National Nuclear Security Administration. The Government is granted for
// itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide
// license in this material to reproduce, prepare derivative works, distribute copies to
// the public, perform publicly and display publicly, and to permit others to do so.
//========================================================================================

// This code was generated in whole or in part by one of OpenAI's generative AI models.

#include <functional>
#include <iostream>
#include <map>
#include <string>

// Temporary testing
void test_function1() {}
void test_function2() {}

int main(int argc, char *argv[]) {
// Map of test names to test functions
std::map<std::string, std::function<void()>> tests = {
{"test1", test_function1}, {"test2", test_function2},
// Add more test mappings here
};

if (argc == 1) {
// No test name provided, run all tests
for (const auto &test : tests) {
std::cout << "Running " << test.first << "..." << std::endl;
test.second();
}
} else {
// Run specified test(s)
for (int i = 1; i < argc; ++i) {
std::string test_name = argv[i];
auto it = tests.find(test_name);
if (it != tests.end()) {
std::cout << "Running " << test_name << "..." << std::endl;
it->second();
} else {
std::cerr << "Test \"" << test_name << "\" not found." << std::endl;
}
}
}

return 0;
}

0 comments on commit fde222a

Please sign in to comment.