Skip to content

Commit

Permalink
etest: Nuke the legacy API
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Dec 24, 2024
1 parent 96477c1 commit d6f67a9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 176 deletions.
12 changes: 7 additions & 5 deletions etest/disabled_test_test.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2022-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"
#include "etest/etest2.h"

#include <iostream>
#include <tuple>

int main() {
etest::Suite s{};

bool ran{};
etest::disabled_test("hi", [&] { ran = true; });
s.disabled_test("hi", [&](etest::IActions &) { ran = true; });

std::ignore = etest::run_all_tests();
std::ignore = s.run();
if (ran) {
std::cerr << "A disabled test ran when it shouldn't have\n";
return 1;
}

std::ignore = etest::run_all_tests({.run_disabled_tests = true});
std::ignore = s.run({.run_disabled_tests = true});
if (!ran) {
std::cerr << "A disabled test didn't run when it should have\n";
return 1;
Expand Down
56 changes: 0 additions & 56 deletions etest/etest.cpp

This file was deleted.

83 changes: 0 additions & 83 deletions etest/etest.h

This file was deleted.

9 changes: 5 additions & 4 deletions etest/expect_eq_failure_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"
#include "etest/etest2.h"

int main() {
etest::test("this should fail", [] { etest::expect_eq(1, 2); });
return etest::run_all_tests();
etest::Suite s{};
s.add_test("this should fail", [](etest::IActions &a) { a.expect_eq(1, 2); });
return s.run();
}
11 changes: 5 additions & 6 deletions etest/expect_failure_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"

using etest::expect;
#include "etest/etest2.h"

int main() {
etest::test("this should fail", [] { expect(false); });
return etest::run_all_tests();
etest::Suite s{};
s.add_test("this should fail", [](etest::IActions &a) { a.expect(false); });
return s.run();
}
6 changes: 3 additions & 3 deletions etest/no_tests_registered_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2023-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"
#include "etest/etest2.h"

// If you try to run tests, but none will run due to them all being filtered out
// or something, that's probably an error.
int main() {
bool failure = etest::run_all_tests() != 0;
bool failure = etest::Suite{}.run() != 0;
return failure ? 0 : 1;
}
9 changes: 5 additions & 4 deletions etest/require_eq_failure_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"
#include "etest/etest2.h"

int main() {
etest::test("this should fail", [] { etest::require_eq(1, 2); });
return etest::run_all_tests();
etest::Suite s{};
s.add_test("this should fail", [](etest::IActions &a) { a.require_eq(1, 2); });
return s.run();
}
11 changes: 5 additions & 6 deletions etest/require_failure_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"

using etest::require;
#include "etest/etest2.h"

int main() {
etest::test("this should fail", [] { require(false); });
return etest::run_all_tests();
etest::Suite s{};
s.add_test("this should fail", [](etest::IActions &a) { a.require(false); });
return s.run();
}
15 changes: 8 additions & 7 deletions etest/success_test.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-FileCopyrightText: 2021 Robin Lindén <[email protected]>
// SPDX-FileCopyrightText: 2021-2024 Robin Lindén <[email protected]>
//
// SPDX-License-Identifier: BSD-2-Clause

#include "etest/etest.h"
#include "etest/etest2.h"

int main() {
etest::test("expect", [] { etest::expect(true); });
etest::test("expect_eq", [] { etest::expect_eq(1, 1); });
etest::test("require", [] { etest::require(true); });
etest::test("require_eq", [] { etest::require_eq(1, 1); });
return etest::run_all_tests();
etest::Suite s{};
s.add_test("expect", [](etest::IActions &a) { a.expect(true); });
s.add_test("expect_eq", [](etest::IActions &a) { a.expect_eq(1, 1); });
s.add_test("require", [](etest::IActions &a) { a.require(true); });
s.add_test("require_eq", [](etest::IActions &a) { a.require_eq(1, 1); });
return s.run();
}
4 changes: 2 additions & 2 deletions unicode/util_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ int main() {
});

s.add_test("CodePointView", [](etest::IActions &a) {
auto into_code_points = [](std::string_view s) {
auto into_code_points = [](std::string_view sv) {
std::vector<std::uint32_t> code_points{};
for (auto cp : CodePointView{s}) {
for (auto cp : CodePointView{sv}) {
code_points.push_back(cp);
}
return code_points;
Expand Down

0 comments on commit d6f67a9

Please sign in to comment.