@@ -34,7 +34,11 @@ AFACT(GetRequiredSizeT_DoesSo)
3434AFACT(GetRequiredFilePathWhichMustExist_DoesSo)
3535AFACT(GetRequiredFolderPathWhichNeedNotExist_DoesSo)
3636// Private Functions
37- AFACT(StaticGetRequiredString_ArgNotInMap_ThrowsOutOfRangeException)
37+ AFACT(StaticGetRequiredSizeT_ArgNotInMap_ThrowsInvalidArgumentException)
38+ AFACT(StaticGetRequiredSizeT_ArgInMapAsNoneValue_ThrowsInvalidArgumentException)
39+ AFACT(StaticGetRequiredSizeT_ArgInMapAsSizeTValue_ReturnsValue)
40+
41+ AFACT(StaticGetRequiredString_ArgNotInMap_ThrowsInvalidArgumentException)
3842AFACT(StaticGetRequiredString_ArgInMapAsNoneValue_ThrowsInvalidArgumentException)
3943AFACT(StaticGetRequiredString_ArgInMapAsStringValue_ReturnsValue)
4044EVIDENCE
@@ -50,7 +54,6 @@ Utils::FileSystemPatherMock* _fileSystemPatherMock = nullptr;
5054map<string, docopt::value> _docoptArgs;
5155string _argName;
5256string _expectedKeyNotFoundInMapExceptionMessage;
53- string _expectedStringKeyNotFoundInMapExceptionMessage;
5457
5558STARTUP
5659{
@@ -63,7 +66,6 @@ STARTUP
6366 _docoptArgs = ZenUnit::RandomOrderedMap<string, docopt::value>();
6467 _argName = ZenUnit::Random<string>() + " _argName" ;
6568 _expectedKeyNotFoundInMapExceptionMessage = Utils::String::ConcatStrings (" Error: Key not found in map: [" , _argName, " ]" );
66- _expectedStringKeyNotFoundInMapExceptionMessage = Utils::String::ConcatStrings (" String key not found in map: [" , _argName, " ]" );
6769}
6870
6971TEST (DefaultConstructor_SetsFieldsToDefaultValues)
@@ -289,7 +291,33 @@ TEST(GetRequiredFolderPathWhichNeedNotExist_DoesSo)
289291
290292// Private Functions
291293
292- TEST (StaticGetRequiredString_ArgNotInMap_ThrowsOutOfRangeException)
294+ TEST (StaticGetRequiredSizeT_ArgNotInMap_ThrowsInvalidArgumentException)
295+ {
296+ THROWS_EXCEPTION (_docoptParser.StaticGetRequiredSizeT (_docoptArgs, _argName),
297+ invalid_argument, _expectedKeyNotFoundInMapExceptionMessage);
298+ }
299+
300+ TEST (StaticGetRequiredSizeT_ArgInMapAsNoneValue_ThrowsInvalidArgumentException)
301+ {
302+ _docoptArgs[_argName] = docopt::value ();
303+ //
304+ const string expectedExceptionMessage = Utils::String::ConcatStrings (
305+ " Key[" , _argName, " ] found in map but with non-size_t value" );
306+ THROWS_EXCEPTION (_docoptParser.StaticGetRequiredSizeT (_docoptArgs, _argName),
307+ invalid_argument, expectedExceptionMessage);
308+ }
309+
310+ TEST (StaticGetRequiredSizeT_ArgInMapAsSizeTValue_ReturnsValue)
311+ {
312+ const size_t sizeTArgumentValue = ZenUnit::Random<size_t >();
313+ _docoptArgs[_argName] = docopt::value (sizeTArgumentValue);
314+ //
315+ const size_t returnedSizeTArgumentValue = _docoptParser.StaticGetRequiredSizeT (_docoptArgs, _argName);
316+ //
317+ ARE_EQUAL (sizeTArgumentValue, returnedSizeTArgumentValue);
318+ }
319+
320+ TEST (StaticGetRequiredString_ArgNotInMap_ThrowsInvalidArgumentException)
293321{
294322 THROWS_EXCEPTION (_docoptParser.StaticGetRequiredString (_docoptArgs, _argName),
295323 invalid_argument, _expectedKeyNotFoundInMapExceptionMessage);
@@ -299,8 +327,10 @@ TEST(StaticGetRequiredString_ArgInMapAsNoneValue_ThrowsInvalidArgumentException)
299327{
300328 _docoptArgs[_argName] = docopt::value ();
301329 //
330+ const string expectedExceptionMessage = Utils::String::ConcatStrings (
331+ " Key[" , _argName, " ] found in map but with non-string value" );
302332 THROWS_EXCEPTION (_docoptParser.StaticGetRequiredString (_docoptArgs, _argName),
303- invalid_argument, _expectedStringKeyNotFoundInMapExceptionMessage );
333+ invalid_argument, expectedExceptionMessage );
304334}
305335
306336TEST (StaticGetRequiredString_ArgInMapAsStringValue_ReturnsValue)
0 commit comments