aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/libutil-support/tests/cli-literate-parser.cc3
-rw-r--r--tests/unit/libutil/chunked-vector.cc1
-rw-r--r--tests/unit/libutil/git.cc1
-rw-r--r--tests/unit/libutil/pool.cc30
-rw-r--r--tests/unit/libutil/references.cc1
5 files changed, 17 insertions, 19 deletions
diff --git a/tests/unit/libutil-support/tests/cli-literate-parser.cc b/tests/unit/libutil-support/tests/cli-literate-parser.cc
index 08ebddebc..4edf434be 100644
--- a/tests/unit/libutil-support/tests/cli-literate-parser.cc
+++ b/tests/unit/libutil-support/tests/cli-literate-parser.cc
@@ -1,4 +1,5 @@
#include "cli-literate-parser.hh"
+#include "escape-string.hh"
#include "libexpr/print.hh"
#include "escape-char.hh"
#include "types.hh"
@@ -41,7 +42,7 @@ auto CLILiterateParser::Node::print() const -> std::string
s << "Output ";
break;
}
- printLiteralString(s, this->text);
+ escapeString(s, this->text);
return s.str();
}
diff --git a/tests/unit/libutil/chunked-vector.cc b/tests/unit/libutil/chunked-vector.cc
index 868d11f6f..4feed568b 100644
--- a/tests/unit/libutil/chunked-vector.cc
+++ b/tests/unit/libutil/chunked-vector.cc
@@ -51,4 +51,3 @@ namespace nix {
}
}
-
diff --git a/tests/unit/libutil/git.cc b/tests/unit/libutil/git.cc
index 5b5715fc2..e9048278a 100644
--- a/tests/unit/libutil/git.cc
+++ b/tests/unit/libutil/git.cc
@@ -30,4 +30,3 @@ namespace nix {
ASSERT_EQ(res->reference, "refs/head/main");
}
}
-
diff --git a/tests/unit/libutil/pool.cc b/tests/unit/libutil/pool.cc
index 127e42dda..3ad4ed3aa 100644
--- a/tests/unit/libutil/pool.cc
+++ b/tests/unit/libutil/pool.cc
@@ -65,21 +65,6 @@ namespace nix {
ASSERT_EQ(pool.capacity(), 0);
}
- TEST(Pool, flushBadDropsOutOfScopeResources) {
- auto isGood = [](const ref<TestResource> & r) { return false; };
- auto createResource = []() { return make_ref<TestResource>(); };
-
- Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource, isGood);
-
- {
- auto _r = pool.get();
- ASSERT_EQ(pool.count(), 1);
- }
-
- pool.flushBad();
- ASSERT_EQ(pool.count(), 0);
- }
-
// Test that the resources we allocate are being reused when they are still good.
TEST(Pool, reuseResource) {
auto isGood = [](const ref<TestResource> & r) { return true; };
@@ -124,4 +109,19 @@ namespace nix {
ASSERT_NE(h->num, counter);
}
}
+
+ TEST(Pool, throwingOperationDropsResource)
+ {
+ auto createResource = []() { return make_ref<TestResource>(); };
+
+ Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource);
+
+ ASSERT_THROW({
+ auto _r = pool.get();
+ ASSERT_EQ(pool.count(), 1);
+ throw 1;
+ }, int);
+
+ ASSERT_EQ(pool.count(), 0);
+ }
}
diff --git a/tests/unit/libutil/references.cc b/tests/unit/libutil/references.cc
index a517d9aa1..be2b59051 100644
--- a/tests/unit/libutil/references.cc
+++ b/tests/unit/libutil/references.cc
@@ -43,4 +43,3 @@ INSTANTIATE_TEST_CASE_P(
);
}
-