Skip to content

Commit

Permalink
Merge pull request #2 from LBNL-ETA/October2024Updates
Browse files Browse the repository at this point in the history
October2024 updates
  • Loading branch information
vidanovic authored Oct 16, 2024
2 parents 9e65876 + d2104f8 commit 40f1a93
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 128 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/build.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

jobs:
build-and-test:
name: ${{ matrix.os }} Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# For more specific OS versions, you can specify them explicitly:
# os: [ubuntu-20.04, windows-2019, macos-11]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: "3.20.0" # Specify the minimum version you need

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install -y ninja
choco install -y llvm # Clang on Windows if needed
# choco install -y visualstudio2019community
shell: pwsh

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install ninja
brew install llvm
- name: Configure CMake
run: |
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++
# Or specify other options as needed
- name: Build
run: cmake --build build

- name: Run tests
run: ctest --test-dir build --output-on-failure
18 changes: 0 additions & 18 deletions CMakeLists-xmlParser.txt

This file was deleted.

19 changes: 0 additions & 19 deletions CMakeLists-xmlParser.txt.in

This file was deleted.

18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.11)

project( THMXParser VERSION 1.1.0 LANGUAGES CXX )
set(LIB_NAME ${PROJECT_NAME})
Expand Down Expand Up @@ -33,7 +33,17 @@ else()
set(DOWNLOAD_GTEST OFF)
endif()

include(CMakeLists-xmlParser.txt)
include(FetchContent)

if(NOT TARGET xmlParser)
FetchContent_Declare(
xmlParser
GIT_REPOSITORY https://github.com/LBNL-ETA/XMLParser.git
GIT_TAG "v1.0.1"
)

FetchContent_MakeAvailable(xmlParser)
endif()

add_subdirectory( src )

Expand All @@ -50,6 +60,10 @@ Option(BUILD_THMX_Parser_Tests "Build tests for thmx file parsing." ON)
if(BUILD_THMX_Parser_Tests)
enable_testing()
add_subdirectory( test )

# Set the path to the test directory
set(TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_compile_definitions(THMXParser-test PRIVATE TEST_DATA_DIR="${TEST_DATA_DIR}")
endif()


8 changes: 8 additions & 0 deletions src/thmxParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ namespace thmxParser
// int shadeID = std::stoi( str );
str = getAttribute(materialNode, "RGBColor");
unsigned int red, green, blue;
#ifdef _MSC_VER
sscanf_s(str.c_str(), "0x%02x%02x%02x", &red, &green, &blue);
#else
std::sscanf(str.c_str(), "0x%02x%02x%02x", &red, &green, &blue);
#endif
ColorRGB color{red, green, blue};
int cavityModel = 0;
str = getAttribute(materialNode, "CavityModel");
Expand Down Expand Up @@ -172,7 +176,11 @@ namespace thmxParser
float temperature = std::stof(str);
str = getAttribute(bcondNode, "RGBColor");
unsigned int red, green, blue;
#ifdef _MSC_VER
sscanf_s(str.c_str(), "0x%02x%02x%02x", &red, &green, &blue);
#else
std::sscanf(str.c_str(), "0x%02x%02x%02x", &red, &green, &blue);
#endif
ColorRGB color{red, green, blue};

str = getAttribute(bcondNode, "Tr");
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ endif()
add_executable(${PROJECT_TEST_NAME}
read_cs_03.unit.cpp
read_cma_example.cpp
main.cpp
paths.h )
main.cpp
)

include_directories(${PROJECT_SOURCE_DIR}/src)

Expand Down
5 changes: 0 additions & 5 deletions test/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include <gtest/gtest.h>

#include "paths.h"

std::string test_dir;

int main( int argc, char* argv[] ) {
#ifdef ENABLE_GTEST_DEBUG_MODE
::testing::GTEST_FLAG(break_on_failure) = true;
::testing::GTEST_FLAG(catch_exceptions) = false;
#endif
::testing::InitGoogleTest( &argc, argv );
test_dir = argv[1];
return RUN_ALL_TESTS();
}

8 changes: 0 additions & 8 deletions test/paths.h

This file was deleted.

27 changes: 7 additions & 20 deletions test/read_cma_example.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
#include <memory>
#include <gtest/gtest.h>
#include <memory>
#include <sstream>
#include <filesystem>

#include "thmxParser.hpp"

#include "paths.h"

extern std::string test_dir;

class TestLoadCMA : public testing::Test
{
protected:
virtual void SetUp()
{}
};


TEST_F(TestLoadCMA, TestLoadCMAFromDisk)
TEST(TestLoadCMA, TestLoadCMAFromDisk)
{
std::filesystem::path product_path(test_dir);
std::filesystem::path product_path(TEST_DATA_DIR);
product_path /= "files";
product_path /= "cma_example.thmx";
auto contents = thmxParser::parseFile(product_path.string());
EXPECT_EQ(contents.fileVersion, "1");
EXPECT_EQ(contents.materials.size(), 5);
EXPECT_EQ(contents.boundaryConditions.size(), 4);
EXPECT_EQ(contents.polygons.size(), 5);
EXPECT_EQ(contents.boundaryConditionPolygons.size(), 11);
EXPECT_EQ(contents.fileVersion, "1");
EXPECT_EQ(contents.materials.size(), 5);
EXPECT_EQ(contents.boundaryConditions.size(), 4);
EXPECT_EQ(contents.polygons.size(), 5);
EXPECT_EQ(contents.boundaryConditionPolygons.size(), 11);
}
24 changes: 7 additions & 17 deletions test/read_cs_03.unit.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
#include <memory>
#include <gtest/gtest.h>
#include <memory>
#include <sstream>
#include <filesystem>

#include "thmxParser.hpp"

#include "paths.h"

extern std::string test_dir;

class TestLoadCS03 : public testing::Test
{
protected:
virtual void SetUp()
{}
};


TEST_F(TestLoadCS03, TestLoadCS03FromDisk)
TEST(TestLoadCS03, TestLoadCS03FromDisk)
{
std::filesystem::path product_path(test_dir);
std::filesystem::path product_path(TEST_DATA_DIR);
product_path /= "files";
product_path /= "CS03.thmx";
//thmxParser::parseFile(product_path.string());

auto contents = thmxParser::parseFile(product_path.string());
EXPECT_EQ(contents.fileVersion, "1");
EXPECT_EQ(contents.boundaryConditions.size(), 4u);
EXPECT_EQ(contents.materials.size(), 13u);
EXPECT_EQ(contents.polygons.size(), 99u);
}

0 comments on commit 40f1a93

Please sign in to comment.