forked from numenta/nupic.core-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a first scenario for Network using CATCH
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "catch.hpp" | ||
|
||
#include <nta/engine/Network.hpp> | ||
#include <nta/engine/NuPIC.hpp> | ||
#include <nta/engine/Region.hpp> | ||
#include <nta/ntypes/Dimensions.hpp> | ||
|
||
using namespace nta; | ||
|
||
SCENARIO( "creating a network should auto-initialize NuPIC", "[network]" ) { | ||
|
||
GIVEN( "uninitialized NuPIC" ) { | ||
|
||
// Uninitialize NuPIC since this test checks auto-initialization | ||
// If shutdown fails, there is probably a problem with another test which | ||
// is not cleaning up its networks. | ||
if (NuPIC::isInitialized()) | ||
{ | ||
NuPIC::shutdown(); | ||
} | ||
|
||
REQUIRE(!NuPIC::isInitialized()); | ||
|
||
|
||
WHEN("creates a network") { | ||
Network net; | ||
|
||
THEN("NuPIC should be initialized") { | ||
CHECK(NuPIC::isInitialized()); | ||
} | ||
|
||
WHEN("adds a region to the network") { | ||
Region *l1 = net.addRegion("level1", "TestNode", ""); | ||
|
||
THEN("region name should be as specified") { | ||
CHECK("level1" == l1->getName()); | ||
} | ||
} | ||
|
||
AND_THEN("NuPIC should fail to shutdown") { | ||
// Network still exists, so this should fail. | ||
CHECK_THROWS(NuPIC::shutdown()); | ||
} | ||
} | ||
|
||
WHEN("No network exists") { | ||
THEN("NuPIC can be shut down") { | ||
// net destructor has been called so we should be able to shut down NuPIC now | ||
CHECK_NOTHROW(NuPIC::shutdown()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file | ||
#include "catch.hpp" | ||
|
||
#include "NetworkTest.hpp" |