-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cbehave and config tests (fixes #52)
- Loading branch information
Showing
13 changed files
with
132 additions
and
34 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "src/tinydir"] | ||
path = src/tinydir | ||
url = https://github.com/cxong/tinydir | ||
[submodule "src/tests/cbehave"] | ||
path = src/tests/cbehave | ||
url = https://github.com/cxong/cbehave.git |
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
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
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ set(CDOGS_SOURCES | |
automap.c | ||
blit.c | ||
config.c | ||
config_apply.c | ||
defs.c | ||
draw.c | ||
drawtools.c | ||
|
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
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
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,38 @@ | ||
/* | ||
C-Dogs SDL | ||
A port of the legendary (and fun) action/arcade cdogs. | ||
Copyright (c) 2013, Cong Xu | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "config.h" | ||
|
||
|
||
void ConfigApply(Config *config) | ||
{ | ||
BlitSetBrightness(config->Graphics.Brightness); | ||
SoundReconfigure(&gSoundDevice, &config->Sound); | ||
gCampaign.seed = config->Game.RandomSeed; | ||
GraphicsInitialize(&gGraphicsDevice, &config->Graphics, 0); | ||
} |
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
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 |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
#ifndef __GRAFX | ||
#define __GRAFX | ||
|
||
#include <SDL.h> | ||
#include <SDL_video.h> | ||
|
||
#include "sys_specifics.h" | ||
|
||
|
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
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,10 @@ | ||
if(MSVC) | ||
add_definitions(-wd"4127" -wd"4102") | ||
endif() | ||
|
||
add_subdirectory(cbehave) | ||
|
||
include_directories(. ../cdogs) | ||
|
||
add_executable(config_test config_test.c ../cdogs/config.h ../cdogs/config.c) | ||
target_link_libraries(config_test cbehave) |
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,56 @@ | ||
#include <cbehave/cbehave.h> | ||
|
||
#include <config.h> | ||
|
||
|
||
FEATURE(1, "Load default config") | ||
SCENARIO("Load a default config") | ||
{ | ||
Config config1, config2; | ||
GIVEN("two configs") | ||
GIVEN_END | ||
|
||
WHEN("I load them both with defaults") | ||
ConfigLoadDefault(&config1); | ||
ConfigLoadDefault(&config2); | ||
WHEN_END | ||
|
||
THEN("they should equal each other") | ||
SHOULD_MEM_EQUAL(&config1, &config2, sizeof(Config)); | ||
THEN_END | ||
} | ||
SCENARIO_END | ||
FEATURE_END | ||
|
||
FEATURE(2, "Save and load") | ||
SCENARIO("Save and load a config file") | ||
{ | ||
Config config1, config2; | ||
GIVEN("a config file with some values, and I save the config to file") | ||
ConfigLoadDefault(&config1); | ||
config1.Game.FriendlyFire = 1; | ||
config1.Graphics.Brightness = 5; | ||
ConfigSave(&config1, "tmp"); | ||
GIVEN_END | ||
|
||
WHEN("I load a second config from that file") | ||
ConfigLoad(&config2, "tmp"); | ||
WHEN_END | ||
|
||
THEN("the two configs should be equal") | ||
SHOULD_MEM_EQUAL(&config1, &config2, sizeof(Config)); | ||
THEN_END | ||
} | ||
SCENARIO_END | ||
FEATURE_END | ||
|
||
int main(void) | ||
{ | ||
cbehave_feature features[] = | ||
{ | ||
{feature_idx(1)}, | ||
{feature_idx(2)} | ||
}; | ||
|
||
return cbehave_runner("Config features are:", features); | ||
} |