summaryrefslogtreecommitdiff
path: root/src/mongo/base/status_test.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2012-10-29 13:11:11 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-11-01 23:06:51 -0400
commit79c550530065678d1611567cf262a7b325c2db47 (patch)
treed7f61dc27a788b4461811494f6fcf7efbcb136ea /src/mongo/base/status_test.cpp
parentbd5d48f9c57df96e2a11933057e9a90392a89e40 (diff)
downloadmongo-79c550530065678d1611567cf262a7b325c2db47.tar.gz
Add an isOK method to Status, and methods to get an ErrorCodes::Error from a string or an int.
Diffstat (limited to 'src/mongo/base/status_test.cpp')
-rw-r--r--src/mongo/base/status_test.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/base/status_test.cpp b/src/mongo/base/status_test.cpp
index 5b0979b4d0f..00f40a42962 100644
--- a/src/mongo/base/status_test.cpp
+++ b/src/mongo/base/status_test.cpp
@@ -63,4 +63,18 @@ namespace {
ASSERT_EQUALS(Status::OK().refCount(), 0);
}
+ TEST(Parsing, CodeToEnum) {
+ ASSERT_EQUALS(ErrorCodes::TypeMismatch, ErrorCodes::fromInt(ErrorCodes::TypeMismatch));
+ ASSERT_EQUALS(ErrorCodes::UnknownError, ErrorCodes::fromInt(ErrorCodes::UnknownError));
+ ASSERT_EQUALS(ErrorCodes::UnknownError, ErrorCodes::fromInt(ErrorCodes::MaxError));
+ ASSERT_EQUALS(ErrorCodes::OK, ErrorCodes::fromInt(0));
+ }
+
+ TEST(Parsing, StringToEnum) {
+ ASSERT_EQUALS(ErrorCodes::TypeMismatch, ErrorCodes::fromString("TypeMismatch"));
+ ASSERT_EQUALS(ErrorCodes::UnknownError, ErrorCodes::fromString("UnknownError"));
+ ASSERT_EQUALS(ErrorCodes::UnknownError, ErrorCodes::fromString("Garbage"));
+ ASSERT_EQUALS(ErrorCodes::OK, ErrorCodes::fromString("OK"));
+ }
+
} // unnamed namespace