Some checks failed
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Failing after 10m53s
Build Packages / build:rpm (rocky8_nocuda) (push) Failing after 11m13s
Build Packages / Generate python client (push) Successful in 31s
Build Packages / build:rpm (rocky8_sls9) (push) Failing after 11m59s
Build Packages / build:rpm (rocky8) (push) Failing after 12m4s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky9_nocuda) (push) Failing after 12m20s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Failing after 12m22s
Build Packages / Build documentation (push) Successful in 54s
Build Packages / build:rpm (ubuntu2204) (push) Failing after 12m32s
Build Packages / build:rpm (rocky9) (push) Failing after 13m2s
Build Packages / build:rpm (ubuntu2404) (push) Failing after 6m11s
Build Packages / Unit tests (push) Failing after 53m18s
40 lines
973 B
C++
40 lines
973 B
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
|
|
#include "../common/hkl_key.h"
|
|
|
|
TEST_CASE("HKL key round-trip", "[hkl_key]") {
|
|
struct Case { int64_t h, k, l; };
|
|
const Case cases[] = {
|
|
{0, 0, 0},
|
|
{1, -2, 3},
|
|
{-511, 0, 511},
|
|
{512 - 1, -(512 - 1), 7},
|
|
{-128, 255, -7}
|
|
};
|
|
|
|
for (const auto& c : cases) {
|
|
const uint64_t key = hkl_key(c.h, c.k, c.l);
|
|
int64_t h = 0, k = 0, l = 0;
|
|
hkl_from_key(key, h, k, l);
|
|
|
|
CHECK(h == c.h);
|
|
CHECK(k == c.k);
|
|
CHECK(l == c.l);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("HKL key boundaries", "[hkl_key]") {
|
|
const int64_t min = -512;
|
|
const int64_t max = 511;
|
|
|
|
const uint64_t key = hkl_key(min, 0, max);
|
|
int64_t h = 0, k = 0, l = 0;
|
|
hkl_from_key(key, h, k, l);
|
|
|
|
CHECK(h == min);
|
|
CHECK(k == 0);
|
|
CHECK(l == max);
|
|
} |