Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linalg] lazy linalg tests #562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linalg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org> ]]

add_subdirectory("eigen")
add_subdirectory("lazy")
add_subdirectory("naive")
30 changes: 30 additions & 0 deletions support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,33 @@ install(
EXPORT "kalman-target"
FILE_SET "kalman_print_headers"
DESTINATION "include/fcarouge")

include(CheckSourceCompiles)
include(FetchContent)

add_library(kalman_generator INTERFACE)

check_source_compiles(
CXX
"
#include <generator>
int main() {}
"
CPP_LIB_GENERATOR)

if(NOT CPP_LIB_GENERATOR)
FetchContent_Declare(
stdgenerator
GIT_REPOSITORY "https://github.com/FrancoisCarouge/generator"
FIND_PACKAGE_ARGS NAMES stdgenerator)
FetchContent_MakeAvailable(stdgenerator)

target_sources(kalman_generator INTERFACE FILE_SET "kalman_generator_headers"
TYPE "HEADERS" FILES "generator")
target_link_libraries(kalman_generator INTERFACE stdgenerator::stdgenerator)
install(
TARGETS kalman_generator
EXPORT "kalman-target"
FILE_SET "kalman_generator_headers"
DESTINATION "include/fcarouge")
endif()
16 changes: 15 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ foreach(
COMMAND ${TEST_COMMAND} $<TARGET_FILE:kalman_test_${NAME}_driver>)
endforeach()

foreach(BACKEND IN ITEMS "eigen" "naive")
foreach(BACKEND IN ITEMS "eigen" "lazy" "naive")
foreach(
TEST
"linalg_addition.cpp"
Expand Down Expand Up @@ -114,3 +114,17 @@ foreach(BACKEND IN ITEMS "eigen")
$<TARGET_FILE:kalman_test_${BACKEND}_${NAME}_driver>)
endforeach()
endforeach()

foreach(BACKEND IN ITEMS "lazy")
foreach(TEST "linalg_constructor_initializer_lists_deduction.cpp")
get_filename_component(NAME ${TEST} NAME_WE)
add_executable(kalman_test_${BACKEND}_${NAME}_driver ${TEST})
target_link_libraries(
kalman_test_${BACKEND}_${NAME}_driver
PRIVATE kalman kalman_main kalman_linalg_${BACKEND} kalman_options)
separate_arguments(TEST_COMMAND UNIX_COMMAND $ENV{COMMAND})
add_test(NAME kalman_test_${BACKEND}_${NAME}
COMMAND ${TEST_COMMAND}
$<TARGET_FILE:kalman_test_${BACKEND}_${NAME}_driver>)
endforeach()
endforeach()
71 changes: 71 additions & 0 deletions test/linalg_constructor_initializer_lists_deduction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* __ _ __ __ _ _
| |/ / /\ | | | \/ | /\ | \ | |
| ' / / \ | | | \ / | / \ | \| |
| < / /\ \ | | | |\/| | / /\ \ | . ` |
| . \ / ____ \| |____| | | |/ ____ \| |\ |
|_|\_\/_/ \_\______|_| |_/_/ \_\_| \_|

Kalman Filter
Version 0.4.0
https://github.com/FrancoisCarouge/Kalman

SPDX-License-Identifier: Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org> */

#include "fcarouge/linalg.hpp"

#include <cassert>

#include <iostream>
#include <typeinfo>

namespace fcarouge::test {
namespace {
//! @test Verifies the initializer lists constructor.
//!
//! @todo Rewrite this test as a property-based test.
//! @todo Static assert the sizes and value type?
[[maybe_unused]] auto test{[] {
matrix m{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {1, 2, 3}};

assert(m(0, 0) == 1);
assert(m(0, 1) == 2);
assert(m(0, 2) == 3);
assert(m(1, 0) == 4);
assert(m(1, 1) == 5);
assert(m(1, 2) == 6);
assert(m(2, 0) == 7);
assert(m(2, 1) == 8);
assert(m(2, 2) == 9);
assert(m(3, 0) == 1);
assert(m(3, 1) == 2);
assert(m(3, 2) == 3);

return 0;
}()};
} // namespace
} // namespace fcarouge::test
Loading