Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
22
The project contains 10 steps that you must implement, however I only want you to do steps 2-6, there is already code functions written and the steps are shown where you need to put them. The assignment provides there is hints which can help you better understand. If you open the battlebit folder and look at the read me, there is more information about the task. You are trying to make the game battle ships. You will also need to have a specific virtual box image (previous version of Ubuntu) to be able to compile and run the code. I can provide this via email. The language is mostly focused on C and has a small amount of Assembly code in it as well. Please review the file and provide a response or question, thank you.
Attachments
csci-366-fall2020-private-master/.gitignore
/battlebit/cmake-build-debug/
repos/student_repos
/battlebit/CMakeFiles/
/battlebit/googletest/CMakeFiles/
csci-366-fall2020-private-master/.idea/.gitignore
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
csci-366-fall2020-private-master/.idea/.name
battleship
csci-366-fall2020-private-master/.idea/csci-366-fall2020.iml
csci-366-fall2020-private-master/.idea/misc.xml
csci-366-fall2020-private-master/.idea/modules.xml
csci-366-fall2020-private-master/.idea/vcs.xml
csci-366-fall2020-private-master/battlebit/CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(battleship C)
enable_language(ASM_NASM)
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
add_executable(battleBit src/main.c src/server.c src/server.h src/repl.c src/repl.h src/game.c src/game.h src/char_buff.c src/char_buff.h src/assembly_demo.asm)
target_link_libraries(battleBit PUBLIC pthread m)
set_source_files_properties(assembly_demo.asm PROPERTIES LANGUAGE ASM_NASM)
add_library(battleBit_lib src/main.c src/server.c src/server.h src/repl.c src/repl.h src/game.c src/game.h src/char_buff.c src/char_buff.h src/assembly_demo.asm)
add_subdirectory(googletest)
csci-366-fall2020-private-master/battlebit/DEMO_SCRIPT.md
# Demo Script
Below is the script and expected behavior of battleBit. You are expected to record a video and upload it to Youtube or
another alternative. If you do not have any screen recording experience, [OBS](https://obsproject.com/) is a cross
platform screen recording software package that can be used.
## Steps
1. ### Server Startup
1. Open three terminals in the following configuration:
```
|------------------|----------------|
| | TERMINAL 2 |
| TERMINAL 1 |----------------|
| | TERMINAL 3 |
|------------------|----------------|
```
1. Terminal 1 will be used to launch battleBit, which can be found in `/battlbit/cmake-build-debug/battleBit`
and which should present you with the following command line options:
```shell script
/home/carson/CLionProjects/battleship/cmake-build-debug/battleBit
Welcome to BattleBit
battleBit (? for help) >
```
1. From the command prompt, run the `server` command, which should start the server listening on port
9876
1. Terminal 2 will be used to connect as Player 0, using the following command:
```
telnet localhost 9876
```
When a player connects through this manner, the server should show the following prompt:
```shell script
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
Welcome to the battleBit server Player 0
battleBit (? for help) >
```
1. Run the `?` command, which should show the following output
```shell script
battleBit (? for help) > ?
? - show help
load <string> - load a ship layout
show - shows the board
fire [0-7] [0-7] - fires at the given position
say <string> - Send the string to all players as part of a chat
exit
battleBit (? for help) >
```
1. ### Game Play Demo
1. ##### Player 0 Out Of Order Fire
Player 0 should try to fire before Player 1 has connected, and see the following output
```shell script
battleBit (? for help) > fire 1 1
Game Has Not Begun!
battleBit (? for help) >
```
1. ##### Player 0 Board Load
Player 0 should then load the following configuration:
```shell script
battleBit (? for help) > load C00b02D23S47p71
Waiting On Player 1
battleBit (? for help) >
```
1. ##### Player 1 Connect
In Terminal 3, Player 1 should connect:
```shell script
$ telnet localhost 9876
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
Welcome to the battleBit server Player 1
battleBit (? for help) >
```
1. ##### Player 1 Board Load
Player 1 should then load the following configuration:
```shell script
battleBit (? for help) > load C07B00d23s61p72
All Player Boards Loaded
Player 0 Turn
battleBit (? for help) >
```
1. ##### Player 1 Out Of Order Fire
Player 0 should try to fire, and see the following output
```shell script
battleBit (? for help) > fire 1 1
Player 0 Turn
battleBit (? for help) >
```
1. ##### Player 1 Talk Functionality
Player 1 should use the `say` command to encourage Player 0 to fire
```shell script
battleBit (? for help) > say Please fire
battleBit (? for help) >
```
Player 0 and the server (Terminal 1) should see the following:
```shell script
battleBit (? for help) >
Player 1 says: Please fire
battleBit (? for help) >
```
1. ##### Firing In Sequence
Player 0 and Player 1 should make the following shots in squence:
1. Player 0: `fire 0 0` - Should show `Player 0 fires at 0 0 - HIT` on all terminals
1. Player 1: `fire 1 1` - Should show `Player 1 fires at 1 1 - MISS` on all terminals
1. Player 0: `fire 7 7` - Should show `Player 0 fires at 1 1 - MISS` on all terminals
1. Player 1: `fire 0 3` - Should show `Player 1 fires at 0 3 - HIT` on all terminals
1. ##### Player 0 board state
In terminal 2, run the show command to show the Player 0's board, which should show the following
output
```shell script
battleBit (? for help) > show
battleBit.........
-----[ ENEMY ]----
0 1 2 3 4 5 6 7
0 H
1
2
3
4
5
6
7 M
==================
-----[ SHIPS ]----
0 1 2 3 4 5 6 7
0 * * * * *
1 *
2 * *
3 * * *
4 *
5 *
6
7 * * *
.........battleBit
```
1. ##### Player 1 board state
In terminal 3, run the show command to show the Player 1's board, which should show the following
output
```shell script
battleBit (? for help) > show
battleBit.........
-----[ ENEMY ]----
0 1 2 3 4 5 6 7
0
1 M
2
3 H
4
5
6
7
==================
-----[ SHIPS ]----
0 1 2 3 4 5 6 7
0 * * *
1 *
2 * *
3 * * *
4 *
5 *
6
7 * * * * *
.........battleBit
```
1. ##### Shortcut
From terminal 1 (the server terminal) run the following command:
```shell script
battleBit (? for help) > shortcut
```
This will set up player 1 to have a single ship bit in position (0, 0)
1. ##### Player 0 Wins
In terminal 2, fire a single shot from Player 0's at position 0, 0, which should show the following
output in all terminals
```shell script
battleBit (? for help) > fire 0 0
Player 0 fires at 0 0 - HIT - PLAYER 0 WINS!
```
csci-366-fall2020-private-master/battlebit/README.md
## battleBit: A bit-wise implementation of BattleShip
The project for CS366 is a bit-based version of [Battleship](https://en.wikipedia.org/wiki/Battleship_(game)). Rather than a 10x10 board as in the original game, battleBit will use an 8x8 board, allowing board state to be stored in a set of 64-bit integers.
### Ships & Board Specifications
A battleBit board consists of five ships:
* Carrier - 5 spaces
* Battleship - 4 spaces
* Destroyer - 3 spaces
* Submarine - 3 spaces
* PatrolBoat - 2 spaces
A battleBit board is specified as follows:
* Five triples of a letter L taken from the set [c, C, b, B, d, D, s, S, p, P] followed by two numbers between 0 and 7. * Each letter corresponds to a ship with the same starting letter.
* The numbers indicate the X and Y position of the start of the ship
* A capital letter indicates that the ship is oriented horizontially, starting at the X, Y postion
* A lower case letter indicates that the ship is oriented vertically, starting at the X, Y position
* By convention, 0, 0 is the upper left position in the board, and 7,7 is the lower left
* So the top row would consist of the positions (0, 0), (1, 0), (2, 0), ..., (7,0)
An example of a board specifications is:
* `C00b02D23S47p71`
```
CCCCC...
.......P
b......P
b.DDD...
b.......
b.......
........
....SSS.
```
### Project Goals
#### Board Display
The initial goal of the project will be to display a board to a player. The struct used to capture a players state in a game looks like this:
```c
typedef struct game_state {
enum Status status;
long long shots;
long long hits;
long long ships;
} game_state;
```
Using this information, students will need to print out an ASCII board representation that looks like this:
```
battleBit........
----[ ENEMY ]----
0 1 2 3 4 5 6 7
0
1 H H
2
3 M
4
5
6
7
=================
----[ SHIPS ]----
0 1 2 3 4 5 6 7
0 * * * * *
1 *
2 * *
3 * * * *
4 *
5 *
6
7 * * *
........battleBit
```
Note that as a bit is hit on a board, it flips from 1 to 0, and thus a losing board is empty.
#### Board Load & Verification
The next step in the project is loading board given the specification above into the `ships` field. Board specifications must be verified to ensure that:
* All ship positions lie within the board boundaries
* No ships overlap
It is sufficient to report one error.
If a specification is erroneous, it should not update the `ships` board.
#### Local Gameplay Implementation
The next step in the project involves implementing local gameplay mechanics. You are provided with a basic Read-Evaluate-Print-Loop (REPL) in `main.c` and `repl.c`. You will need to implement the following commands:
```
? - show help
load [0-1] <string> - load a ship layout specification for the given player
show [0-1] - shows the board for the given player
say <string> - Send the string to all players as part of a chat
fire [0-1] [0-7] [0-7] - the given player fires at the given position
reset - reset the game
server - start the server
exit - quit
```
You have been provided with a helper library `char_buff.h/char_buff.c` that makes it easier to deal with strings in the project.
You can play a full, if fake, game with just a server by loading two player boards and then alternating fires between them.
#### Network Gameplay Implementation
The final step in the project is adding network functionality that allows two players to connect via `telnet` to the server and begin a game. The server waits until two players have connected and then begins the game, coordinating responses and managing turns between the two players.
The server also supports a `say` command that allows the players to talk with one another during the game, even if it is not a given players turn. It also allows the server command line to observe the chat as well as participate in it. Note that this functionality requires synchronization to avoid corruption of the chat order.
The client commands are:
```
? - show help
load <string> - load a ship layout specification for the current player
show - shows the board for the current player
say <string> - Send the string to all players as part of a chat
fire [0-7] [0-7] - fire at the given position of the opponent
exit - quit the server
```
#### Grading Rubric
The grading will be mainly based on automated tests. However, a major component of the project is network programming, which is difficult to test in an automated manner, and will require us to run and test your application manually. Additionally, you will be required to record a demo of the application running in network mode, with a specfic set of commands.
The grading will break down like so:
* 60% automated tests
* 15% recorded demo
* 15% manual testing of the network component by instructors
* 10% code quality and proper synchronization
csci-366-fall2020-private-master/battlebit/googletest/.idea/.gitignore
# Default ignored files
/shelf/
/workspace.xml
csci-366-fall2020-private-master/battlebit/googletest/.idea/.name
battleship
csci-366-fall2020-private-master/battlebit/googletest/.idea/googletest.iml
csci-366-fall2020-private-master/battlebit/googletest/.idea/googletest1.iml
csci-366-fall2020-private-master/battlebit/googletest/.idea/misc.xml
csci-366-fall2020-private-master/battlebit/googletest/.idea/modules.xml
csci-366-fall2020-private-master/battlebit/googletest/.idea/vcs.xml
csci-366-fall2020-private-master/battlebit/googletest/CMakeLists.txt
# 'Google_test' is the subproject name
project(Google_tests)
# 'lib' is the folder with Google Test sources
add_subdirectory(lib)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ../src)
# 'Google_Tests_run' is the target name
add_executable(battleBit_tests char_buff.cpp game.cpp repl.cpp)
target_link_libraries(battleBit_tests gtest gtest_main battleBit_lib)
add_executable(homework_2 homework_2.cpp)
target_link_libraries(homework_2 gtest gtest_main battleBit_lib)
enable_language(ASM_NASM)
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
set_source_files_properties(homework_3.asm PROPERTIES LANGUAGE ASM_NASM)
add_executable(homework_3 homework_3.cpp homework_3.asm)
target_link_libraries(homework_3 gtest gtest_main)
csci-366-fall2020-private-master/battlebit/googletest/char_buff.cpp
#include "gtest/gtest.h"
extern "C" {
#include "char_buff.h"
}
TEST(char_buff, bootstrap) {
struct char_buff *buffer = cb_create(2000);
cb_print(buffer);
EXPECT_TRUE(strcmp(buffer->buffer, "") == 0);
cb_append(buffer, "Foo");
cb_print(buffer);
EXPECT_TRUE(strcmp(buffer->buffer, "Foo") == 0);
cb_append(buffer, "Foo");
cb_print(buffer);
EXPECT_TRUE(strcmp(buffer->buffer, "FooFoo") == 0);
cb_free(buffer);
}
TEST(char_buff, noOverFlow) {
struct char_buff *buffer = cb_create(3);
EXPECT_TRUE(strcmp(buffer->buffer, "") == 0);
cb_print(buffer);
cb_append(buffer, "Foo");
cb_print(buffer);
EXPECT_TRUE(strcmp(buffer->buffer, "Foo") == 0);
cb_append(buffer, "Foo");
cb_print(buffer);
EXPECT_TRUE(strcmp(buffer->buffer, "Foo") == 0);
cb_free(buffer);
}
TEST(char_buff, tokenize) {
struct char_buff *buffer = cb_create(200);
cb_append(buffer, "Foo Bar Baz");
EXPECT_TRUE(strcmp(cb_tokenize(buffer, " "), "Foo") == 0);
EXPECT_TRUE(strcmp(cb_next_token(buffer), "Bar") == 0);
EXPECT_TRUE(strcmp(cb_next_token(buffer), "Baz") == 0);
cb_free(buffer);
}
csci-366-fall2020-private-master/battlebit/googletest/game.cpp
#include "gtest/gtest.h"
extern "C" {
#include "game.h"
}
TEST(xy_to_bitval, good_values) {
// row 1
EXPECT_EQ(xy_to_bitval(0, 0), 1ull);
EXPECT_EQ(xy_to_bitval(1, 0), 2ull);
EXPECT_EQ(xy_to_bitval(2, 0), 4ull);
EXPECT_EQ(xy_to_bitval(3, 0), 8ull);
EXPECT_EQ(xy_to_bitval(4, 0), 16ull);
EXPECT_EQ(xy_to_bitval(5, 0), 32ull);
EXPECT_EQ(xy_to_bitval(6, 0), 64ull);
EXPECT_EQ(xy_to_bitval(7, 0), 128ull);
// row 2
EXPECT_EQ(xy_to_bitval(0, 1), 256ull);
EXPECT_EQ(xy_to_bitval(1, 1), 512ull);
EXPECT_EQ(xy_to_bitval(2, 1), 1024ull);
EXPECT_EQ(xy_to_bitval(3, 1), 2048ull);
EXPECT_EQ(xy_to_bitval(4, 1), 4096ull);
EXPECT_EQ(xy_to_bitval(5, 1), 8192ull);
EXPECT_EQ(xy_to_bitval(6, 1), 16384ull);
EXPECT_EQ(xy_to_bitval(7, 1), 32768ull);
// start of row 7
EXPECT_EQ(xy_to_bitval(0, 7), 1ull << 56ull);
// end of row 7
EXPECT_EQ(xy_to_bitval(7, 7), 1ull << 63ull);
}
TEST(xy_to_bitval, bad_values) {
EXPECT_EQ(xy_to_bitval(0, 8), 0);
EXPECT_EQ(xy_to_bitval(8, 0), 0);
EXPECT_EQ(xy_to_bitval(-1, 0), 0);
EXPECT_EQ(xy_to_bitval(0, -1), 0);
}
TEST(game_fire,empty_game){
game_init();
struct game * gameon = game_get_current();
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(game_fire(gameon,1,0,0),0);
}
TEST(game_fire,hit_fire){
game_init();
struct game * gameon = game_get_current();
char * spec = "C00b02D23S47p71";
game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(game_fire(gameon,1,0,0),1);
ASSERT_EQ(game_fire(gameon,1,1,0),1);
ASSERT_EQ(game_fire(gameon,1,2,0),1);
ASSERT_EQ(game_fire(gameon,1,3,0),1);
ASSERT_EQ(game_fire(gameon,1,4,0),1);
ASSERT_EQ(game_fire(gameon,1,7,1),1);
ASSERT_EQ(game_fire(gameon,1,0,2),1);
ASSERT_EQ(game_fire(gameon,1,7,2),1);
ASSERT_EQ(game_fire(gameon,1,0,3),1);
ASSERT_EQ(game_fire(gameon,1,2,3),1);
ASSERT_EQ(game_fire(gameon,1,3,3),1);
ASSERT_EQ(game_fire(gameon,1,4,3),1);
ASSERT_EQ(game_fire(gameon,1,0,4),1);
ASSERT_EQ(game_fire(gameon,1,0,5),1);
ASSERT_EQ(game_fire(gameon,1,5,7),1);
ASSERT_EQ(game_fire(gameon,1,6,7),1);
ASSERT_EQ(game_fire(gameon,1,4,7),1);
}
TEST(game_fire,miss_fire){
game_init();
struct game * gameon = game_get_current();
char * spec = "C00b02D23S47p71";
game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(game_fire(gameon,1,5,0),0);
ASSERT_EQ(game_fire(gameon,1,6,0),0);
ASSERT_EQ(game_fire(gameon,1,7,0),0);
ASSERT_EQ(game_fire(gameon,1,0,1),0);
ASSERT_EQ(game_fire(gameon,1,1,1),0);
ASSERT_EQ(game_fire(gameon,1,2,1),0);
ASSERT_EQ(game_fire(gameon,1,3,1),0);
ASSERT_EQ(game_fire(gameon,1,4,1),0);
ASSERT_EQ(game_fire(gameon,1,5,1),0);
ASSERT_EQ(game_fire(gameon,1,6,1),0);
ASSERT_EQ(game_fire(gameon,1,1,2),0);
ASSERT_EQ(game_fire(gameon,1,2,2),0);
ASSERT_EQ(game_fire(gameon,1,3,2),0);
ASSERT_EQ(game_fire(gameon,1,4,2),0);
ASSERT_EQ(game_fire(gameon,1,5,2),0);
ASSERT_EQ(game_fire(gameon,1,6,2),0);
ASSERT_EQ(game_fire(gameon,1,1,3),0);
ASSERT_EQ(game_fire(gameon,1,5,3),0);
ASSERT_EQ(game_fire(gameon,1,6,3),0);
ASSERT_EQ(game_fire(gameon,1,7,3),0);
ASSERT_EQ(game_fire(gameon,1,1,4),0);
ASSERT_EQ(game_fire(gameon,1,2,4),0);
ASSERT_EQ(game_fire(gameon,1,3,4),0);
ASSERT_EQ(game_fire(gameon,1,4,4),0);
ASSERT_EQ(game_fire(gameon,1,5,4),0);
ASSERT_EQ(game_fire(gameon,1,6,4),0);
ASSERT_EQ(game_fire(gameon,1,7,4),0);
ASSERT_EQ(game_fire(gameon,1,1,5),0);
ASSERT_EQ(game_fire(gameon,1,2,5),0);
ASSERT_EQ(game_fire(gameon,1,3,5),0);
ASSERT_EQ(game_fire(gameon,1,4,5),0);
ASSERT_EQ(game_fire(gameon,1,5,5),0);
ASSERT_EQ(game_fire(gameon,1,6,5),0);
ASSERT_EQ(game_fire(gameon,1,7,5),0);
ASSERT_EQ(game_fire(gameon,1,0,6),0);
ASSERT_EQ(game_fire(gameon,1,1,6),0);
ASSERT_EQ(game_fire(gameon,1,2,6),0);
ASSERT_EQ(game_fire(gameon,1,3,6),0);
ASSERT_EQ(game_fire(gameon,1,4,6),0);
ASSERT_EQ(game_fire(gameon,1,5,6),0);
ASSERT_EQ(game_fire(gameon,1,6,6),0);
ASSERT_EQ(game_fire(gameon,1,7,6),0);
ASSERT_EQ(game_fire(gameon,1,0,7),0);
ASSERT_EQ(game_fire(gameon,1,1,7),0);
ASSERT_EQ(game_fire(gameon,1,2,7),0);
ASSERT_EQ(game_fire(gameon,1,3,7),0);
ASSERT_EQ(game_fire(gameon,1,7,7),0);
}
TEST(game_fire,invalid_fire){
game_init();
struct game * gameon = game_get_current();
char * spec = "C00b02D23S47p71";
game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(game_fire(gameon,1,8,0),0);
ASSERT_EQ(game_fire(gameon,1,0,8),0);
ASSERT_EQ(game_fire(gameon,1,0,-1),0);
ASSERT_EQ(game_fire(gameon,1,-1,0),0);
}
TEST(add_ship_horizontal,empty_ship){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
game_init_player_info(player_info);
//char * spec = "C00b02D23S47p71";
//game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(add_ship_horizontal(player_info,1,8,0),1);
}
TEST(add_ship_horizontal,load_ship){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
game_init_player_info(player_info);
//char * spec = "C00b02D23S47p71";
//game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(add_ship_horizontal(player_info,0,0,5),1); // C-> length = 5
ASSERT_EQ(add_ship_horizontal(player_info,4,0,4),-1); //overlapping ship B-> length = 4
}
TEST(add_ship_vertical,empty_ship){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
game_init_player_info(player_info);
//char * spec = "C00b02D23S47p71";
//game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(add_ship_vertical(player_info,1,8,0),1);
}
TEST(add_ship_vertical,load_ship){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
game_init_player_info(player_info);
//char * spec = "C00b02D23S47p71";
//game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(add_ship_vertical(player_info,0,0,5),1); // C-> length = 5
ASSERT_EQ(add_ship_vertical(player_info,0,4,4),-1); //overlapping ship B-> length = 4
}
TEST(game_load_board,empty_spec){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
//game_init_player_info(player_info);
//char * spec = "C00b02D23S47p71";
//game_load_board(gameon, 0, spec);
//EXPECT_TRUE(strcmp("Baz", "Baz") == 0);
ASSERT_EQ(game_load_board(gameon,0,NULL),-1);
}
TEST(game_load_board,incomplete_spec){
game_init();
struct game * gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
//game_init_player_info(player_info);
char * spec = "C00b02D23S47";//incomplete spec
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C-1-1b02D23S47p71";//invalid spec
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "A00b02D23S47p71";//invalid spec
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00c02D23S47p71";//invalid spec- Multiple carriers
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "B00b02D23S47p71";//invalid spec- Multiple batleships
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00b02D23S47d71";//invalid spec- Multiple destroyers
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00b02D23S47s71";//invalid spec- Multiple ships
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00P02D23S47p71";//invalid spec- Multiple patrol boats
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C60P02D23S47p71";//invalid spec- horizontal out of bound
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00b02D23S47p77";//invalid spec- vertical out of bound
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00b02D30S47p71";//invalid spec- horizontal Overlaps
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
spec = "C00b02D23S47p01";//invalid spec- vertical Overlaps
ASSERT_EQ(game_load_board(gameon,0,spec),-1);
}
TEST(game_load_board,valid_spec) {
game_init();
struct game *gameon = game_get_current();
struct player_info *player_info = &gameon->players[0];
//game_init_player_info(player_info);
char *spec = "C00b02D23S47p71";
ASSERT_EQ(game_load_board(gameon, 0, spec), 1);
}
TEST(game_status, is_correct) {
game_init();
game *pGame = game_get_current();
ASSERT_EQ(CREATED, pGame->status);
char *spec = "C00b02D23S47p71";
// player 0 set, still in CREATED STATE
ASSERT_EQ(game_load_board(pGame, 0, spec), 1);
ASSERT_EQ(CREATED, pGame->status);
// player 1 set, now in PLAYER_0_TURN
ASSERT_EQ(game_load_board(pGame, 1, spec), 1);
ASSERT_EQ(PLAYER_0_TURN, pGame->status);
// player 0 fires, now PLAYER_1_TURN
ASSERT_EQ(game_fire(pGame,0,0,0),1);
ASSERT_EQ(PLAYER_1_TURN, pGame->status);
player_info *player0 = &pGame->players[0];
player0->ships = 1ull; // set ships to only in (1, 1)
// player 1 shoots at (1, 1)
ASSERT_EQ(game_fire(pGame,1,0,0),1);
// no ships left for player 0, player 1 wins
ASSERT_EQ(PLAYER_1_WINS, pGame->status);
}
csci-366-fall2020-private-master/battlebit/googletest/homework_2.cpp
#include "gtest/gtest.h"
#include "iomanip"
char * print_binary_representation(unsigned int i, char *buffer){
buffer[0] = '0';
buffer[1] = 'b';
// fill out remaining 32 bits, 1 or 0 depending on the value in the number i
return buffer;
}
/* PROBLEM 1: Implement a print_binary_representation function that takes an
* unsigned integer and created as string representation of the binary values
* of that number.
*
* The test below show what the expected values are for given inputs
*/
void print_binary_representation(unsigned n, char buffer) {
for (n = 0; n <= 4; n++) { //loops through the 0-4 integers and prints them out
if (n > 1)
print_binary_representation(n / 2, buffer);
std::cout << "0b" << n % 2;
}
int k = 31431234;
int j = 467813213;
std::cout << "0b" << k % 2;
std::cout << "0b" << j % 2;
std::cout << "0b" << UINT32_MAX % 2;
}
TEST(print_binary_representation, works) {
// row 1
char buffer[50] = {0}; // init to 0
EXPECT_STREQ("0b00000000000000000000000000000000", print_binary_representation(0, buffer));
EXPECT_STREQ("0b00000000000000000000000000000001", print_binary_representation(1, buffer));
EXPECT_STREQ("0b00000000000000000000000000000010", print_binary_representation(2, buffer));
EXPECT_STREQ("0b00000000000000000000000000000011", print_binary_representation(3, buffer));
EXPECT_STREQ("0b00000000000000000000000000000100", print_binary_representation(4, buffer));
EXPECT_STREQ("0b00000001110111111001101001000010", print_binary_representation(31431234, buffer));
EXPECT_STREQ("0b00011011111000100100001101011101", print_binary_representation(467813213, buffer));
EXPECT_STREQ("0b11111111111111111111111111111111", print_binary_representation(UINT32_MAX, buffer));
}
/* PROBLEM 2: The test below fails. Change the signature of set_my_age and the
* call of the function in get_my_age so that the expected value is returned.
*
* HINT: C is pass by value
*/
struct Person {
char * name;
int age = 44;
};
void set_my_age(Person p) { // pass by value, want to have an integer called
p.age = 44;
}
int get_my_age() {
struct Person me;
me.name = "Carson";
set_my_age(me);
return me.age;
}
TEST(set_my_age, works) {
EXPECT_EQ(44, get_my_age());
}
csci-366-fall2020-private-master/battlebit/googletest/lib/.clang-format
# Run manually to reformat a file:
# clang-format -i --style=file <file>
Language: Cpp
BasedOnStyle: Google
csci-366-fall2020-private-master/battlebit/googletest/lib/.gitignore
# Ignore CI build directory
build/
xcuserdata
cmake-build-debug/
.idea/
bazel-bin
bazel-genfiles
bazel-googletest
bazel-out
bazel-testlogs
# python
*.pyc
# Visual Studio files
.vs
*.sdf
*.opensdf
*.VC.opendb
*.suo
*.user
_ReSharper.Caches/
Win32-Debug/
Win32-Release/
x64-Debug/
x64-Release/
# Ignore autoconf / automake files
Makefile.in
aclocal.m4
configure
build-aux/
autom4te.cache/
googletest/m4/libtool.m4
googletest/m4/ltoptions.m4
googletest/m4/ltsugar.m4
googletest/m4/ltversion.m4
googletest/m4/lt~obsolete.m4
googlemock/m4
# Ignore generated directories.
googlemock/fused-src/
googletest/fused-src/
# macOS files
.DS_Store
googletest/.DS_Store
googletest/xcode/.DS_Store
# Ignore cmake generated directories and files.
CMakeFiles
CTestTestfile.cmake
Makefile
cmake_install.cmake
googlemock/CMakeFiles
googlemock/CTestTestfile.cmake
googlemock/Makefile
googlemock/cmake_install.cmake
googlemock/gtest
/bin
/googlemock/gmock.dir
/googlemock/gmock_main.dir
/googlemock/RUN_TESTS.vcxproj.filters
/googlemock/RUN_TESTS.vcxproj
/googlemock/INSTALL.vcxproj.filters
/googlemock/INSTALL.vcxproj
/googlemock/gmock_main.vcxproj.filters
/googlemock/gmock_main.vcxproj
/googlemock/gmock.vcxproj.filters
/googlemock/gmock.vcxproj
/googlemock/gmock.sln
/googlemock/ALL_BUILD.vcxproj.filters
/googlemock/ALL_BUILD.vcxproj
/lib
/Win32
/ZERO_CHECK.vcxproj.filters
/ZERO_CHECK.vcxproj
/RUN_TESTS.vcxproj.filters
/RUN_TESTS.vcxproj
/INSTALL.vcxproj.filters
/INSTALL.vcxproj
/googletest-distribution.sln
/CMakeCache.txt
/ALL_BUILD.vcxproj.filters
/ALL_BUILD.vcxproj
csci-366-fall2020-private-master/battlebit/googletest/lib/.travis.yml
# Build matrix / environment variable are explained on:
# https://docs.travis-ci.com/user/customizing-the-build/
# This file can be validated on:
# http://lint.travis-ci.org/
language: cpp
# Define the matrix explicitly, manually expanding the combinations of (os, compiler, env).
# It is more tedious, but grants us far more flexibility.
matrix:
include:
- os: linux
before_install: chmod -R +x ./ci/*platformio.sh
install: ./ci/install-platformio.sh
script: ./ci/build-platformio.sh
- os: linux
dist: bionic
compiler: gcc
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/build-linux-bazel.sh
- os: linux
dist: bionic
compiler: clang
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/build-linux-bazel.sh
- os: linux
dist: bionic
compiler: gcc
env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated"
- os: linux
dist: bionic
compiler: clang
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON
- os: osx
compiler: gcc
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp
- os: osx
compiler: clang
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp
# These are the install and build (script) phases for the most common entries in the matrix. They could be included
# in each entry in the matrix, but that is just repetitive.
install:
- ./ci/install-${TRAVIS_OS_NAME}.sh
- . ./ci/env-${TRAVIS_OS_NAME}.sh
- ./ci/log-config.sh
script: ./ci/travis.sh
# This section installs the necessary dependencies.
addons:
apt:
packages:
- g++
- clang
update: true
homebrew:
packages:
- ccache
- gcc@4.9
- llvm@4
update: true
notifications:
email: false
csci-366-fall2020-private-master/battlebit/googletest/lib/BUILD.bazel
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
#
# Bazel Build for Google C++ Testing Framework(Google Test)
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
config_setting(
name = "windows",
constraint_values = ["@bazel_tools//platforms:windows"],
)
config_setting(
name = "has_absl",
values = {"define": "absl=1"},
)
# Library that defines the FRIEND_TEST macro.
cc_library(
name = "gtest_prod",
hdrs = ["googletest/include/gtest/gtest_prod.h"],
includes = ["googletest/include"],
)
# Google Test including Google Mock
cc_library(
name = "gtest",
srcs = glob(
include = [
"googletest/src/*.cc",
"googletest/src/*.h",
"googletest/include/gtest/**/*.h",
"googlemock/src/*.cc",
"googlemock/include/gmock/**/*.h",
],
exclude = [
"googletest/src/gtest-all.cc",
"googletest/src/gtest_main.cc",
"googlemock/src/gmock-all.cc",
"googlemock/src/gmock_main.cc",
],
),
hdrs = glob([
"googletest/include/gtest/*.h",
"googlemock/include/gmock/*.h",
]),
copts = select({
":windows": [],
"//conditions:default": ["-pthread"],
}),
defines = select({
":has_absl": ["GTEST_HAS_ABSL=1"],
"//conditions:default": [],
}),
features = select({
":windows": ["windows_export_all_symbols"],
"//conditions:default": [],
}),
includes = [
"googlemock",
"googlemock/include",
"googletest",
"googletest/include",
],
linkopts = select({
":windows": [],
"//conditions:default": ["-pthread"],
}),
deps = select({
":has_absl": [
"@com_google_absl//absl/debugging:failure_signal_handler",
"@com_google_absl//absl/debugging:stacktrace",
"@com_google_absl//absl/debugging:symbolize",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:any",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:variant",
],
"//conditions:default": [],
}),
)
cc_library(
name = "gtest_main",
srcs = ["googlemock/src/gmock_main.cc"],
features = select({
":windows": ["windows_export_all_symbols"],
"//conditions:default": [],
}),
deps = [":gtest"],
)
# The following rules build samples of how to use gTest.
cc_library(
name = "gtest_sample_lib",
srcs = [
"googletest/samples/sample1.cc",
"googletest/samples/sample2.cc",
"googletest/samples/sample4.cc",
],
hdrs = [
"googletest/samples/prime_tables.h",
"googletest/samples/sample1.h",
"googletest/samples/sample2.h",
"googletest/samples/sample3-inl.h",
"googletest/samples/sample4.h",
],
features = select({
":windows": ["windows_export_all_symbols"],
"//conditions:default": [],
}),
)
cc_test(
name = "gtest_samples",
size = "small",
# All Samples except:
# sample9 (main)
# sample10 (main and takes a command line option and needs to be separate)
srcs = [
"googletest/samples/sample1_unittest.cc",
"googletest/samples/sample2_unittest.cc",
"googletest/samples/sample3_unittest.cc",
"googletest/samples/sample4_unittest.cc",
"googletest/samples/sample5_unittest.cc",
"googletest/samples/sample6_unittest.cc",
"googletest/samples/sample7_unittest.cc",
"googletest/samples/sample8_unittest.cc",
],
linkstatic = 0,
deps = [
"gtest_sample_lib",
":gtest_main",
],
)
cc_test(
name = "sample9_unittest",
size = "small",
srcs = ["googletest/samples/sample9_unittest.cc"],
deps = [":gtest"],
)
cc_test(
name = "sample10_unittest",
size = "small",
srcs = ["googletest/samples/sample10_unittest.cc"],
deps = [":gtest"],
)
csci-366-fall2020-private-master/battlebit/googletest/lib/CMakeLists.txt
# Note: CMake support is community-based. The maintainers do not use CMake
# internally.
cmake_minimum_required(VERSION 2.8.8)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
project(googletest-distribution)
set(GOOGLETEST_VERSION 1.10.0)
if (CMAKE_VERSION VERSION_GREATER "3.0.2")
if(NOT CYGWIN AND NOT MSYS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
endif()
enable_testing()
include(CMakeDependentOption)
include(GNUInstallDirs)
#Note that googlemock target already builds googletest
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
if(BUILD_GMOCK)
add_subdirectory( googlemock )
else()
add_subdirectory( googletest )
endif()
csci-366-fall2020-private-master/battlebit/googletest/lib/CONTRIBUTING.md
# How to become a contributor and submit your own code
## Contributor License Agreements
We'd love to accept your patches! Before we can take them, we have to jump a
couple of legal hurdles.
Please fill out either the individual or corporate Contributor License Agreement
(CLA).
* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an
[individual CLA](https://developers.google.com/open-source/cla/individual).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.
## Are you a Googler?
If you are a Googler, please make an attempt to submit an internal change rather
than a GitHub Pull Request. If you are not able to submit an internal change a
PR is acceptable as an alternative.
## Contributing A Patch
1. Submit an issue describing your proposed change to the
[issue tracker](https://github.com/google/googletest/issues).
2. Please don't mix more than one logical change per submittal, because it
makes the history hard to follow. If you want to make a change that doesn't
have a corresponding issue in the issue tracker, please create one.
3. Also, coordinate with team members that are listed on the issue in question.
This ensures that work isn't being duplicated and communicating your plan
early also generally leads to better patches.
4. If your proposed change is accepted, and you haven't already done so, sign a
Contributor License Agreement (see details above).
5. Fork the desired repo, develop and test your code changes.
6. Ensure that your code adheres to the existing style in the sample to which
you are contributing.
7. Ensure that your code has an appropriate set of unit tests which all pass.
8. Submit a pull request.
## The Google Test and Google Mock Communities
The Google Test community exists primarily through the
[discussion group](http://groups.google.com/group/googletestframework) and the
GitHub repository. Likewise, the Google Mock community exists primarily through
their own [discussion group](http://groups.google.com/group/googlemock). You are
definitely encouraged to contribute to the discussion and you can also help us
to keep the effectiveness of the group high by following and promoting the
guidelines listed here.
### Please Be Friendly
Showing courtesy and respect to others is a vital part of the Google culture,
and we strongly encourage everyone participating in Google Test development to
join us in accepting nothing less. Of course, being courteous is not the same as
failing to constructively disagree with each other, but it does mean that we
should be respectful of each other when enumerating the 42 technical reasons
that a particular proposal may not be the best choice. There's never a reason to
be antagonistic or dismissive toward anyone who is sincerely trying to
contribute to a discussion.
Sure, C++ testing is serious business and all that, but it's also a lot of fun.
Let's keep it that way. Let's strive to be one of the friendliest communities in
all of open source.
As always, discuss Google Test in the official GoogleTest discussion group. You
don't have to actually submit code in order to sign up. Your participation
itself is a valuable contribution.
## Style
To keep the source consistent, readable, diffable and easy to merge, we use a
fairly rigid coding style, as defined by the
[google-styleguide](https://github.com/google/styleguide) project. All patches
will be expected to conform to the style outlined
[here](https://google.github.io/styleguide/cppguide.html). Use
[.clang-format](https://github.com/google/googletest/blob/master/.clang-format)
to check your formatting.
## Requirements for Contributors
If you plan to contribute a patch, you need to build Google Test, Google Mock,
and their own tests from a git checkout, which has further requirements:
* [Python](https://www.python.org/) v2.3 or newer (for running some of the
tests and re-generating certain source files from templates)
* [CMake](https://cmake.org/) v2.6.4 or newer
## Developing Google Test and Google Mock
This section discusses how to make your own changes to the Google Test project.
### Testing Google Test and Google Mock Themselves
To make sure your changes work as intended and don't break existing
functionality, you'll want to compile and run Google Test and GoogleMock's own
tests. For that you can use CMake:
mkdir mybuild
cd mybuild
cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR}
To choose between building only Google Test or Google Mock, you may modify your
cmake command to be one of each
cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests
cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests
Make sure you have Python installed, as some of Google Test's tests are written
in Python. If the cmake command complains about not being able to find Python
(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it
explicitly where your Python executable can be found:
cmake -DPYTHON_EXECUTABLE=path/to/python ...
Next, you can build Google Test and / or Google Mock and all desired tests. On
\*nix, this is usually done by
make
To run the tests, do
make test
All tests should pass.
### Regenerating Source Files
Some of Google Test's source files are generated from templates (not in the C++
sense) using a script. For example, the file
*googlemock/include/gmock/gmock-generated-actions.h.pump* is used to generate
*gmock-generated-actions.h* in the same directory.
You don't need to worry about regenerating the source files unless you need to
modify them. You would then modify the corresponding `.pump` files and run the
'[pump.py](googlemock/scripts/pump.py)' generator script. See the
[Pump Manual](googlemock/docs/pump_manual.md).
csci-366-fall2020-private-master/battlebit/googletest/lib/LICENSE
Copyright 2008, Google Inc.
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.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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
OWNER 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.
csci-366-fall2020-private-master/battlebit/googletest/lib/README.md
# Google Test
#### OSS Builds Status:
[](https://travis-ci.org/google/googletest)
[](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)
### Announcements:
#### Release 1.10.x
[Release 1.10.x](https://github.com/google/googletest/releases/tag/release-1.10.0)
is now available.
#### Coming Soon
* Post 1.10.x googletest will follow
[Abseil Live at Head philosophy](https://abseil.io/about/philosophy)
* We are also planning to take a dependency on
[Abseil](https://github.com/abseil/abseil-cpp).
## Welcome to **Google Test**, Google's C++ test framework!
This repository is a merger of the formerly separate GoogleTest and GoogleMock
projects. These were so closely related that it makes sense to maintain and
release them together.
Please subscribe to the mailing list at googletestframework@googlegroups.com for
questions, discussions, and development.
### Getting started:
The information for **Google Test** is available in the
[Google Test Primer](googletest/docs/primer.md) documentation.
**Google Mock** is an extension to Google Test for writing and using C++ mock
classes. See the separate [Google Mock documentation](googlemock/README.md).
More detailed documentation for googletest is in its interior
[googletest/README.md](googletest/README.md) file.
## Features
* An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework.
* Test discovery.
* A rich set of assertions.
* User-defined assertions.
* Death tests.
* Fatal and non-fatal failures.
* Value-parameterized tests.
* Type-parameterized tests.
* Various options for running the tests.
* XML test report generation.
## Platforms
Google test has been used on a variety of platforms:
* Linux
* Mac OS X
* Windows
* Cygwin
* MinGW
* Windows Mobile
* Symbian
* PlatformIO
## Who Is Using Google Test?
In addition to many internal projects at Google, Google Test is also used by the
following notable projects:
* The [Chromium projects](http://www.chromium.org/) (behind the Chrome browser
and Chrome OS).
* The [LLVM](http://llvm.org/) compiler.
* [Protocol Buffers](https://github.com/google/protobuf), Google's data
interchange format.
* The [OpenCV](http://opencv.org/) computer vision library.
* [tiny-dnn](https://github.com/tiny-dnn/tiny-dnn): header only,
dependency-free deep learning framework in C++11.
## Related Open Source Projects
[GTest Runner](https://github.com/nholthaus/gtest-runner) is a Qt5 based
automated test-runner and Graphical User Interface with powerful features for
Windows and Linux platforms.
[Google Test UI](https://github.com/ospector/gtest-gbar) is test runner that
runs your test binary, allows you to track its progress via a progress bar, and
displays a list of test failures. Clicking on one shows failure text. Google
Test UI is written in C#.
[GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event
listener for Google Test that implements the
[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test
result output. If your test runner understands TAP, you may find it useful.
[gtest-parallel](https://github.com/google/gtest-parallel) is a test runner that
runs tests from your binary in parallel to provide significant speed-up.
[GoogleTest Adapter](https://marketplace.visualstudio.com/items?itemName=DavidSchuldenfrei.gtest-adapter)
is a VS Code extension allowing to view Google Tests in a tree view, and
run/debug your tests.
[C++ TestMate](https://github.com/matepek/vscode-catch2-test-adapter) is a VS
Code extension allowing to view Google Tests in a tree view, and run/debug your
tests.
[Cornichon](https://pypi.org/project/cornichon/) is a small Gherkin DSL parser
that generates stub code for Google Test.
## Requirements
Google Test is designed to have fairly minimal requirements to build and use
with your projects, but there are some. If you notice any problems on your
platform, please notify
[googletestframework@googlegroups.com](https://groups.google.com/forum/#!forum/googletestframework).
Patches for fixing them are welcome!
### Build Requirements
These are the base requirements to build and use Google Test from a source
package:
* [Bazel](https://bazel.build/) or [CMake](https://cmake.org/). NOTE: Bazel is
the build system that googletest is using internally and tests against.
CMake is community-supported.
* a C++11-standard-compliant compiler
## Contributing change
Please read the [`CONTRIBUTING.md`](CONTRIBUTING.md) for details on how to
contribute to this project.
Happy testing!
csci-366-fall2020-private-master/battlebit/googletest/lib/WORKSPACE
workspace(name = "com_google_googletest")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Abseil
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
strip_prefix = "abseil-cpp-master",
)
http_archive(
name = "rules_cc",
strip_prefix = "rules_cc-master",
urls = ["https://github.com/bazelbuild/rules_cc/archive/master.zip"],
)
http_archive(
name = "rules_python",
strip_prefix = "rules_python-master",
urls = ["https://github.com/bazelbuild/rules_python/archive/master.zip"],
)
csci-366-fall2020-private-master/battlebit/googletest/lib/appveyor.yml
version: '{build}'
os: Visual Studio 2015
environment:
matrix:
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017"
build_system: cmake
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
enabled_on_pr: yes
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017 Win64"
build_system: cmake
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
enabled_on_pr: yes
- compiler: msvc-15-seh
build_system: bazel
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
enabled_on_pr: yes
- compiler: msvc-14-seh
build_system: cmake
generator: "Visual Studio 14 2015"
enabled_on_pr: yes
- compiler: msvc-14-seh
build_system: cmake
generator: "Visual Studio 14 2015 Win64"
enabled_on_pr: yes
- compiler: gcc-6.3.0-posix
build_system: cmake
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin'
enabled_on_pr: yes
configuration:
- Debug
build:
verbosity: minimal
install:
- ps: |
Write-Output "Compiler: $env:compiler"
Write-Output "Generator: $env:generator"
Write-Output "Env:Configuation: $env:configuration"
Write-Output "Env: $env"
if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) {
Write-Output "This is *NOT* a pull request build"
} else {
Write-Output "This is a pull request build"
if (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes") {
Write-Output "PR builds are *NOT* explicitly enabled"
}
}
# install Bazel
if ($env:build_system -eq "bazel") {
appveyor DownloadFile https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel-0.28.1-windows-x86_64.exe -FileName bazel.exe
}
if ($env:build_system -eq "cmake") {
# git bash conflicts with MinGW makefiles
if ($env:generator -eq "MinGW Makefiles") {
$env:path = $env:path.replace("C:\Program Files\Git\usr\bin;", "")
if ($env:cxx_path -ne "") {
$env:path += ";$env:cxx_path"
}
}
}
before_build:
- ps: |
$env:root=$env:APPVEYOR_BUILD_FOLDER
Write-Output "env:root: $env:root"
build_script:
- ps: |
# Only enable some builds for pull requests, the AppVeyor queue is too long.
if ((Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER) -And (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes")) {
return
} else {
# special case - build with Bazel
if ($env:build_system -eq "bazel") {
& $env:root\bazel.exe build -c opt //:gtest_samples
if ($LastExitCode -eq 0) { # bazel writes to StdErr and PowerShell interprets it as an error
$host.SetShouldExit(0)
} else { # a real error
throw "Exec: $ErrorMessage"
}
return
}
}
# by default build with CMake
md _build -Force | Out-Null
cd _build
$conf = if ($env:generator -eq "MinGW Makefiles") {"-DCMAKE_BUILD_TYPE=$env:configuration"} else {"-DCMAKE_CONFIGURATION_TYPES=Debug;Release"}
# Disable test for MinGW (gtest tests fail, gmock tests can not build)
$gtest_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgtest_build_tests=OFF"} else {"-Dgtest_build_tests=ON"}
$gmock_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgmock_build_tests=OFF"} else {"-Dgmock_build_tests=ON"}
& cmake -G "$env:generator" $conf -Dgtest_build_samples=ON $gtest_build_tests $gmock_build_tests ..
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage"
}
$cmake_parallel = if ($env:generator -eq "MinGW Makefiles") {"-j2"} else {"/m"}
& cmake --build . --config $env:configuration -- $cmake_parallel
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage"
}
skip_commits:
files:
- '**/*.md'
test_script:
- ps: |
# Only enable some builds for pull requests, the AppVeyor queue is too long.
if ((Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER) -And (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes")) {
return
}
if ($env:build_system -eq "bazel") {
# special case - testing with Bazel
& $env:root\bazel.exe test //:gtest_samples
if ($LastExitCode -eq 0) { # bazel writes to StdErr and PowerShell interprets it as an error
$host.SetShouldExit(0)
} else { # a real error
throw "Exec: $ErrorMessage"
}
}
if ($env:build_system -eq "cmake") {
# built with CMake - test with CTest
if ($env:generator -eq "MinGW Makefiles") {
return # No test available for MinGW
}
& ctest -C $env:configuration --timeout 600 --output-on-failure
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage"
}
}
artifacts:
- path: '_build/CMakeFiles/*.log'
name: logs
- path: '_build/Testing/**/*.xml'
name: test_results
- path: 'bazel-testlogs/**/test.log'
name: test_logs
- path: 'bazel-testlogs/**/test.xml'
name: test_results
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/build-linux-bazel.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
set -e
bazel version
bazel test --curses=no //...:all
bazel test --curses=no //...:all --define absl=1
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/build-platformio.sh
# run PlatformIO builds
platformio run
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/env-linux.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
#
# This file should be sourced, and not executed as a standalone script.
#
# TODO() - we can check if this is being sourced using $BASH_VERSION and $BASH_SOURCE[0] != ${0}.
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
if [ "$CXX" = "g++" ]; then export CXX="g++" CC="gcc"; fi
if [ "$CXX" = "clang++" ]; then export CXX="clang++" CC="clang"; fi
fi
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/env-osx.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
#
# This file should be sourced, and not executed as a standalone script.
#
# TODO() - we can check if this is being sourced using $BASH_VERSION and $BASH_SOURCE[0] != ${0}.
#
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
if [ "$CXX" = "clang++" ]; then
# $PATH needs to be adjusted because the llvm tap doesn't install the
# package to /usr/local/bin, etc, like the gcc tap does.
# See: https://github.com/Homebrew/legacy-homebrew/issues/29733
clang_version=3.9
export PATH="/usr/local/opt/llvm@${clang_version}/bin:$PATH";
fi
fi
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/get-nprocessors.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
# This file is typically sourced by another script.
# if possible, ask for the precise number of processors,
# otherwise take 2 processors as reasonable default; see
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
if [ -x /usr/bin/getconf ]; then
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
else
NPROCESSORS=2
fi
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
# crashes if parallelized too much (maybe memory consumption problem),
# so limit to 4 processors for the time being.
if [ $NPROCESSORS -gt 4 ] ; then
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
NPROCESSORS=4
fi
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/install-linux.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
set -eu
if [ "${TRAVIS_OS_NAME}" != linux ]; then
echo "Not a Linux build; skipping installation"
exit 0
fi
if [ "${TRAVIS_SUDO}" = "true" ]; then
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | \
sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install -y bazel gcc g++ clang
elif [ "${CXX}" = "clang++" ]; then
# Use ccache, assuming $HOME/bin is in the path, which is true in the Travis build environment.
ln -sf /usr/bin/ccache $HOME/bin/${CXX};
ln -sf /usr/bin/ccache $HOME/bin/${CC};
fi
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/install-osx.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
set -eu
if [ "${TRAVIS_OS_NAME}" != "osx" ]; then
echo "Not a macOS build; skipping installation"
exit 0
fi
brew update
brew install ccache gcc@4.9
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/install-platformio.sh
# install PlatformIO
sudo pip install -U platformio
# update PlatformIO
platformio update
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/log-config.sh
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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
# OWNER 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.
set -e
# ccache on OS X needs installation first
# reset ccache statistics
ccache --zero-stats
echo PATH=${PATH}
echo "Compiler configuration:"
echo CXX=${CXX}
echo CC=${CC}
echo CXXFLAGS=${CXXFLAGS}
echo "C++ compiler version:"
${CXX} --version || echo "${CXX} does not seem to support the --version flag"
${CXX} -v || echo "${CXX} does not seem to support the -v flag"
echo "C compiler version:"
${CC} --version || echo "${CXX} does not seem to support the --version flag"
${CC} -v || echo "${CXX} does not seem to support the -v flag"
csci-366-fall2020-private-master/battlebit/googletest/lib/ci/travis.sh
#!/usr/bin/env sh
set -evx
. ci/get-nprocessors.sh
# Tell make to use the processors. No preceding '-' required.
MAKEFLAGS="j${NPROCESSORS}"
export MAKEFLAGS
env | sort
# Set default values to OFF for these variables if not specified.
: "${NO_EXCEPTION:=OFF}"
: "${NO_RTTI:=OFF}"
: "${COMPILER_IS_GNUCXX:=OFF}"
mkdir build || true
cd build
cmake -Dgtest_build_samples=ON \
-Dgtest_build_tests=ON \
-Dgmock_build_tests=ON \
-Dcxx_no_exception="$NO_EXCEPTION" \
-Dcxx_no_rtti="$NO_RTTI" \
-DCMAKE_COMPILER_IS_GNUCXX="$COMPILER_IS_GNUCXX" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
..
make
CTEST_OUTPUT_ON_FAILURE=1 make test
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/CMakeLists.txt
########################################################################
# Note: CMake support is community-based. The maintainers do not use CMake
# internally.
#
# CMake build script for Google Mock.
#
# To run the tests for Google Mock itself on Linux, use 'make test' or
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
option(gmock_build_tests "Build all of Google Mock's own tests." OFF)
# A directory to find Google Test sources.
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt")
set(gtest_dir gtest)
else()
set(gtest_dir ../googletest)
endif()
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL)
if (COMMAND pre_project_set_up_hermetic_build)
# Google Test also calls hermetic setup functions from add_subdirectory,
# although its changes will not affect things at the current scope.
pre_project_set_up_hermetic_build()
endif()
########################################################################
#
# Project-wide settings
# Name of the project.
#
# CMake files in this project can refer to the root source directory
# as ${gmock_SOURCE_DIR} and to the root binary directory as
# ${gmock_BINARY_DIR}.
# Language "C" is required for find_package(Threads).
if (CMAKE_VERSION VERSION_LESS 3.0)
project(gmock CXX C)
else()
cmake_policy(SET CMP0048 NEW)
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
endif()
cmake_minimum_required(VERSION 2.6.4)
if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()
# Instructs CMake to process Google Test's CMakeLists.txt and add its
# targets to the current scope. We are placing Google Test's binary
# directory in a subdirectory of our own as VC compilation may break
# if they are the same (the default).
add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/${gtest_dir}")
# These commands only run if this is the main project
if(CMAKE_PROJECT_NAME STREQUAL "gmock" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
else()
mark_as_advanced(gmock_build_tests)
endif()
# Although Google Test's CMakeLists.txt calls this function, the
# changes there don't affect the current scope. Therefore we have to
# call it again here.
config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
# Adds Google Mock's and Google Test's header directories to the search path.
set(gmock_build_include_dirs
"${gmock_SOURCE_DIR}/include"
"${gmock_SOURCE_DIR}"
"${gtest_SOURCE_DIR}/include"
# This directory is needed to build directly from Google Test sources.
"${gtest_SOURCE_DIR}")
include_directories(${gmock_build_include_dirs})
########################################################################
#
# Defines the gmock & gmock_main libraries. User tests should link
# with one of them.
# Google Mock libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that Google Mock can be compiled by
# a user aggressive about warnings.
if (MSVC)
cxx_library(gmock
"${cxx_strict}"
"${gtest_dir}/src/gtest-all.cc"
src/gmock-all.cc)
cxx_library(gmock_main
"${cxx_strict}"
"${gtest_dir}/src/gtest-all.cc"
src/gmock-all.cc
src/gmock_main.cc)
else()
cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
target_link_libraries(gmock PUBLIC gtest)
set_target_properties(gmock PROPERTIES VERSION ${GOOGLETEST_VERSION})
cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
target_link_libraries(gmock_main PUBLIC gmock)
set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
endif()
# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
target_include_directories(gmock SYSTEM INTERFACE
"$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(gmock_main SYSTEM INTERFACE
"$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
endif()
########################################################################
#
# Install rules
install_project(gmock gmock_main)
########################################################################
#
# Google Mock's own tests.
#
# You can skip this section if you aren't interested in testing
# Google Mock itself.
#
# The tests are not built by default. To build them, set the
# gmock_build_tests option to ON. You can do it by running ccmake
# or specifying the -Dgmock_build_tests=ON flag when running cmake.
if (gmock_build_tests)
# This must be set in the root directory for the tests to be run by
# 'make test' or ctest.
enable_testing()
if (WIN32)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/RunTest.ps1"
CONTENT
"$project_bin = \"${CMAKE_BINARY_DIR}/bin/$<CONFIG>\"
$env:Path = \"$project_bin;$env:Path\"
& $args")
elseif (MINGW OR CYGWIN)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1"
CONTENT
"$project_bin = (cygpath --windows ${CMAKE_BINARY_DIR}/bin)
$env:Path = \"$project_bin;$env:Path\"
& $args")
endif()
if (MINGW OR CYGWIN)
if (CMAKE_VERSION VERSION_LESS "2.8.12")
add_compile_options("-Wa,-mbig-obj")
else()
add_definitions("-Wa,-mbig-obj")
endif()
endif()
############################################################
# C++ tests built with standard compiler flags.
cxx_test(gmock-actions_test gmock_main)
cxx_test(gmock-cardinalities_test gmock_main)
cxx_test(gmock_ex_test gmock_main)
cxx_test(gmock-function-mocker_test gmock_main)
cxx_test(gmock-generated-actions_test gmock_main)
cxx_test(gmock-generated-matchers_test gmock_main)
cxx_test(gmock-internal-utils_test gmock_main)
cxx_test(gmock-matchers_test gmock_main)
cxx_test(gmock-more-actions_test gmock_main)
cxx_test(gmock-nice-strict_test gmock_main)
cxx_test(gmock-port_test gmock_main)
cxx_test(gmock-spec-builders_test gmock_main)
cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc)
cxx_test(gmock_test gmock_main)
if (DEFINED GTEST_HAS_PTHREAD)
cxx_test(gmock_stress_test gmock)
endif()
# gmock_all_test is commented to save time building and running tests.
# Uncomment if necessary.
# cxx_test(gmock_all_test gmock_main)
############################################################
# C++ tests built with non-standard compiler flags.
if (MSVC)
cxx_library(gmock_main_no_exception "${cxx_no_exception}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
else()
cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
target_link_libraries(gmock_main_no_exception PUBLIC gmock)
cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
target_link_libraries(gmock_main_no_rtti PUBLIC gmock)
endif()
cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
gmock_main_no_exception test/gmock-more-actions_test.cc)
cxx_test_with_flags(gmock_no_rtti_test "${cxx_no_rtti}"
gmock_main_no_rtti test/gmock-spec-builders_test.cc)
cxx_shared_library(shared_gmock_main "${cxx_default}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
# Tests that a binary can be built with Google Mock as a shared library. On
# some system configurations, it may not possible to run the binary without
# knowing more details about the system configurations. We do not try to run
# this binary. To get a more robust shared library coverage, configure with
# -DBUILD_SHARED_LIBS=ON.
cxx_executable_with_flags(shared_gmock_test_ "${cxx_default}"
shared_gmock_main test/gmock-spec-builders_test.cc)
set_target_properties(shared_gmock_test_
PROPERTIES
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
############################################################
# Python tests.
cxx_executable(gmock_leak_test_ test gmock_main)
py_test(gmock_leak_test)
cxx_executable(gmock_output_test_ test gmock)
py_test(gmock_output_test)
endif()
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/CONTRIBUTORS
# This file contains a list of people who've made non-trivial
# contribution to the Google C++ Mocking Framework project. People
# who commit code to the project are encouraged to add their names
# here. Please keep the list sorted by first names.
Benoit Sigoure <tsuna@google.com>
Bogdan Piloca <boo@google.com>
Chandler Carruth <chandlerc@google.com>
Dave MacLachlan <dmaclach@gmail.com>
David Anderson <danderson@google.com>
Dean Sturtevant
Gene Volovich <gv@cite.com>
Hal Burch <gmock@hburch.com>
Jeffrey Yasskin <jyasskin@google.com>
Jim Keller <jimkeller@google.com>
Joe Walnes <joe@truemesh.com>
Jon Wray <jwray@google.com>
Keir Mierle <mierle@gmail.com>
Keith Ray <keith.ray@gmail.com>
Kostya Serebryany <kcc@google.com>
Lev Makhlis
Manuel Klimek <klimek@google.com>
Mario Tanev <radix@google.com>
Mark Paskin
Markus Heule <markus.heule@gmail.com>
Matthew Simmons <simmonmt@acm.org>
Mike Bland <mbland@google.com>
Neal Norwitz <nnorwitz@gmail.com>
Nermin Ozkiranartli <nermin@google.com>
Owen Carlsen <ocarlsen@google.com>
Paneendra Ba <paneendra@google.com>
Paul Menage <menage@google.com>
Piotr Kaminski <piotrk@google.com>
Russ Rufer <russ@pentad.com>
Sverre Sundsdal <sundsdal@gmail.com>
Takeshi Yoshino <tyoshino@google.com>
Vadim Berman <vadimb@google.com>
Vlad Losev <vladl@google.com>
Wolfgang Klier <wklier@google.com>
Zhanyong Wan <wan@google.com>
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/LICENSE
Copyright 2008, Google Inc.
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.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
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
OWNER 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.
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/README.md
# Googletest Mocking (gMock) Framework
### Overview
Google's framework for writing and using C++ mock classes. It can help you
derive better designs of your system and write better tests.
It is inspired by:
* [jMock](http://www.jmock.org/)
* [EasyMock](http://www.easymock.org/)
* [Hamcrest](http://code.google.com/p/hamcrest/)
It is designed with C++'s specifics in mind.
gMock:
- Provides a declarative syntax for defining mocks.
- Can define partial (hybrid) mocks, which are a cross of real and mock
objects.
- Handles functions of arbitrary types and overloaded functions.
- Comes with a rich set of matchers for validating function arguments.
- Uses an intuitive syntax for controlling the behavior of a mock.
- Does automatic verification of expectations (no record-and-replay needed).
- Allows arbitrary (partial) ordering constraints on function calls to be
expressed.
- Lets a user extend it by defining new matchers and actions.
- Does not use exceptions.
- Is easy to learn and use.
Details and examples can be found here:
* [gMock for Dummies](docs/for_dummies.md)
* [Legacy gMock FAQ](docs/gmock_faq.md)
* [gMock Cookbook](docs/cook_book.md)
* [gMock Cheat Sheet](docs/cheat_sheet.md)
Please note that code under scripts/generator/ is from the [cppclean
project](http://code.google.com/p/cppclean/) and under the Apache
License, which is different from Google Mock's license.
Google Mock is a part of
[Google Test C++ testing framework](http://github.com/google/googletest/) and a
subject to the same requirements.
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/cmake/gmock.pc.in
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gmock
Description: GoogleMock (without main() function)
Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gtest = @PROJECT_VERSION@
Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/cmake/gmock_main.pc.in
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gmock_main
Description: GoogleMock (with main() function)
Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gmock = @PROJECT_VERSION@
Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
csci-366-fall2020-private-master/battlebit/googletest/lib/googlemock/docs/cheat_sheet.md
# gMock Cheat Sheet
<!-- GOOGLETEST_CM0019 DO NOT DELETE -->
<!-- GOOGLETEST_CM0033 DO NOT DELETE -->
## Defining a Mock Class
### Mocking a Normal Class {#MockClass}
Given
```cpp
class Foo {
...
virtual ~Foo();
virtual int GetSize() const = 0;
virtual string Describe(const char* name) = 0;
virtual string Describe(int type) = 0;
virtual bool Process(Bar elem, int count) = 0;
};
```
(note that `~Foo()` **must** be virtual) we can define its mock as
```cpp
#include "gmock/gmock.h"
class MockFoo : public Foo {
...
MOCK_METHOD(int, GetSize, (), (const, override));
MOCK_METHOD(string, Describe, (const char* name), (override));
MOCK_METHOD(string, Describe, (int type), (override));
MOCK_METHOD(bool, Process, (Bar elem, int count), (override));
};
```
To create a "nice" mock, which ignores all uninteresting calls, a "naggy" mock,
which warns on all uninteresting calls, or a "strict" mock, which treats them as
failures:
```cpp
using ::testing::NiceMock;
using ::testing::NaggyMock;
using ::testing::StrictMock;
NiceMock<MockFoo> nice_foo; // The type is a subclass of MockFoo.
NaggyMock<MockFoo> naggy_foo; // The type is a subclass of MockFoo.
StrictMock<MockFoo> strict_foo; // The type is a subclass of MockFoo.
```
**Note:** A mock object is currently naggy by default. We may make it nice by
default in the future.
### Mocking a Class Template {#MockTemplate}
Class templates can be mocked just like any class.
To mock
```cpp
template <typename Elem>
class StackInterface {
...
virtual ~StackInterface();
virtual int GetSize() const = 0;
virtual void Push(const Elem& x) = 0;
};
```
(note that all member functions that are mocked, including `~StackInterface()`
**must** be virtual).
```cpp
template <typename Elem>
class MockStack : public StackInterface<Elem> {
...
MOCK_METHOD(int, GetSize, (), (const, override));
MOCK_METHOD(void, Push, (const Elem& x), (override));
};
```
### Specifying Calling Conventions for Mock Functions
If your mock function doesn't use the default calling convention, you can
specify it by adding `Calltype(convention)` to `MOCK_METHOD`'s 4th parameter.
For example,
```cpp
MOCK_METHOD(bool, Foo, (int n), (Calltype(STDMETHODCALLTYPE)));
MOCK_METHOD(int, Bar, (double x, double y),
(const, Calltype(STDMETHODCALLTYPE)));
```
where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows.
## Using Mocks in Tests {#UsingMocks}
The typical work flow is:
1. Import the gMock names you need to use. All gMock symbols are in the
`testing` namespace unless they are macros or otherwise noted.
2. Create the mock objects.
3. Optionally, set the default actions of the mock objects.
4. Set your expectations on the mock objects (How will they be called? What
will they do?).
5. Exercise code that uses the mock objects; if necessary, check the result
using googletest assertions.
6. When a mock object is destructed, gMock automatically verifies that all
expectations on it have been satisfied.
Here's an example:
```cpp
using ::testing::Return; // #1
TEST(BarTest, DoesThis) {
MockFoo foo; // #2
ON_CALL(foo, GetSize()) // #3
.WillByDefault(Return(1));
// ... other default actions ...
EXPECT_CALL(foo, Describe(5)) // #4
.Times(3)
.WillRepeatedly(Return("Category 5"));
// ... other expectations ...
EXPECT_EQ("good", MyProductionFunction(&foo)); // #5
} // #6
```
## Setting Default Actions {#OnCall}
gMock has a **built-in default action** for any function that returns `void`,
`bool`, a numeric value, or a pointer. In C++11, it will additionally returns
the default-constructed value, if one exists for the given type.
To customize the default action for functions with return type *`T`*:
```cpp
using ::testing::DefaultValue;
// Sets the default value to be returned. T must be CopyConstructible.
DefaultValue<T>::Set(value);
// Sets a factory. Will be invoked on demand. T must be MoveConstructible.
// T MakeT();
DefaultValue<T>::SetFactory(&MakeT);
// ... use the mocks ...
// Resets the default value.
DefaultValue<T>::Clear();
```
Example usage:
```cpp
// Sets the default action for return type std::unique_ptr<Buzz> to
// creating a new Buzz every time.
DefaultValue<std::unique_ptr<Buzz>>::SetFactory(
[] { return MakeUnique<Buzz>(AccessLevel::kInternal); });
// When this fires, the default action of MakeBuzz() will run, which
// will return a new Buzz object.
EXPECT_CALL(mock_buzzer_, MakeBuzz("hello")).Times(AnyNumber());
auto buzz1 = mock_buzzer_.MakeBuzz("hello");
auto buzz2 = mock_buzzer_.MakeBuzz("hello");
EXPECT_NE(nullptr, buzz1);
EXPECT_NE(nullptr, buzz2);
EXPECT_NE(buzz1, buzz2);
// Resets the default action for return type std::unique_ptr<Buzz>,
// to avoid interfere with other tests.
DefaultValue<std::unique_ptr<Buzz>>::Clear();
```
To customize the default action for a particular method of a specific mock
object, use `ON_CALL()`. `ON_CALL()` has a similar syntax to `EXPECT_CALL()`,
but it is used for setting default behaviors (when you do not require that the
mock method is called). See [here](cook_book.md#UseOnCall) for a more detailed
discussion.
```cpp
ON_CALL(mock-object, method(matchers))
.With(multi-argument-matcher) ?
.WillByDefault(action);
```
## Setting Expectations {#ExpectCall}
`EXPECT_CALL()` sets **expectations** on a mock method (How will it be called?
What will it do?):
```cpp
EXPECT_CALL(mock-object, method (matchers)?)
.With(multi-argument-matcher) ?
.Times(cardinality) ?
.InSequence(sequences) *
.After(expectations) *
.WillOnce(action) *
.WillRepeatedly(action) ?
.RetiresOnSaturation(); ?
```
For each item above, `?` means it can be used at most once, while `*` means it
can be used any number of times.
In order to pass, `EXPECT_CALL` must be used before the calls are actually made.
The `(matchers)` is a comma-separated list of matchers that correspond to each
of the arguments of `method`, and sets the expectation only for calls of
`method` that matches all of the matchers.
If `(matchers)` is omitted, the expectation is the same as if the matchers were
set to anything matchers (for example, `(_, _, _, _)` for a four-arg method).
If `Times()` is omitted, the cardinality is assumed to be:
* `Times(1)` when there is neither `WillOnce()` nor `WillRepeatedly()`;
* `Times(n)` when there are `n` `WillOnce()`s but no `WillRepeatedly()`, where
`n` >= 1; or
* `Times(AtLeast(n))` when there are `n` `WillOnce()`s and a
`WillRepeatedly()`, where `n` >= 0.
A method with no `EXPECT_CALL()` is free to be invoked *any number of times*,
and the default action will be taken each time.
## Matchers {#MatcherList}
<!-- GOOGLETEST_CM0020 DO NOT DELETE -->
A **matcher** matches a *single* argument. You can use it inside `ON_CALL()` or
`EXPECT_CALL()`, or use it to validate a value directly using two macros:
<!-- mdformat off(github rendering does not support multiline tables) -->
| Macro | Description |
| :----------------------------------- | :------------------------------------ |
| `EXPECT_THAT(actual_value, matcher)` | Asserts that `actual_value` matches `matcher`. |
| `ASSERT_THAT(actual_value, matcher)` | The same as `EXPECT_THAT(actual_value, matcher)`, except that it generates a **fatal** failure. |
<!-- mdformat on -->
**Note:** Although equality matching via `EXPECT_THAT(actual_value,
expected_value)` is supported, prefer to make the comparison explicit via
`EXPECT_THAT(actual_value, Eq(expected_value))` or `EXPECT_EQ(actual_value,
expected_value)`.
Built-in matchers (where `argument` is the function argument, e.g.
`actual_value` in the example above, or when used in the context of
`EXPECT_CALL(mock_object, method(matchers))`, the arguments of `method`) are
divided into several categories:
### Wildcard
Matcher | Description
:-------------------------- | :-----------------------------------------------
`_` | `argument` can be any value of the correct type.
`A<type>()` or `An<type>()` | `argument` can be any value of type `type`.
### Generic Comparison
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :--------------------- | :-------------------------------------------------- |
| `Eq(value)` or `value` | `argument == value` |
| `Ge(value)` | `argument >= value` |
| `Gt(value)` | `argument > value` |
| `Le(value)` | `argument <= value` |
| `Lt(value)` | `argument < value` |
| `Ne(value)` | `argument != value` |
| `IsFalse()` | `argument` evaluates to `false` in a Boolean context. |
| `IsTrue()` | `argument` evaluates to `true` in a Boolean context. |
| `IsNull()` | `argument` is a `NULL` pointer (raw or smart). |
| `NotNull()` | `argument` is a non-null pointer (raw or smart). |
| `Optional(m)` | `argument` is `optional<>` that contains a value matching `m`. (For testing whether an `optional<>` is set, check for equality with `nullopt`. You may need to use `Eq(nullopt)` if the inner type doesn't have `==`.)|
| `VariantWith<T>(m)` | `argument` is `variant<>` that holds the alternative of type T with a value matching `m`. |
| `Ref(variable)` | `argument` is a reference to `variable`. |
| `TypedEq<type>(value)` | `argument` has type `type` and is equal to `value`. You may need to use this instead of `Eq(value)` when the mock function is overloaded. |
<!-- mdformat on -->
Except `Ref()`, these matchers make a *copy* of `value` in case it's modified or
destructed later. If the compiler complains that `value` doesn't have a public
copy constructor, try wrap it in `ByRef()`, e.g.
`Eq(ByRef(non_copyable_value))`. If you do that, make sure `non_copyable_value`
is not changed afterwards, or the meaning of your matcher will be changed.
`IsTrue` and `IsFalse` are useful when you need to use a matcher, or for types
that can be explicitly converted to Boolean, but are not implicitly converted to
Boolean. In other cases, you can use the basic
[`EXPECT_TRUE` and `EXPECT_FALSE`](../../googletest/docs/primer#basic-assertions)
assertions.
### Floating-Point Matchers {#FpMatchers}
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------------- | :--------------------------------- |
| `DoubleEq(a_double)` | `argument` is a `double` value approximately equal to `a_double`, treating two NaNs as unequal. |
| `FloatEq(a_float)` | `argument` is a `float` value approximately equal to `a_float`, treating two NaNs as unequal. |
| `NanSensitiveDoubleEq(a_double)` | `argument` is a `double` value approximately equal to `a_double`, treating two NaNs as equal. |
| `NanSensitiveFloatEq(a_float)` | `argument` is a `float` value approximately equal to `a_float`, treating two NaNs as equal. |
| `IsNan()` | `argument` is any floating-point type with a NaN value. |
<!-- mdformat on -->
The above matchers use ULP-based comparison (the same as used in googletest).
They automatically pick a reasonable error bound based on the absolute value of
the expected value. `DoubleEq()` and `FloatEq()` conform to the IEEE standard,
which requires comparing two NaNs for equality to return false. The
`NanSensitive*` version instead treats two NaNs as equal, which is often what a
user wants.
<!-- mdformat off(no multiline tables) -->
| Matcher | Description |
| :------------------------------------------------ | :----------------------- |
| `DoubleNear(a_double, max_abs_error)` | `argument` is a `double` value close to `a_double` (absolute error <= `max_abs_error`), treating two NaNs as unequal. |
| `FloatNear(a_float, max_abs_error)` | `argument` is a `float` value close to `a_floa
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: 8X8 Battleship In C or similar questions only at Tutlance.
Related Questions
- C Battleship Project
- Bowling Scores Java
- Online Degrees Visual Basic Assignment
- C++ Timecard Winforms
- Maze Project In Mips Assembly Code
- C++ Battleships Assignment
- Final Project For Neuro Data Programming Class
- C++ And Assembly Battleship Game
- Powershell And Linux
- C Virtual Memory Simulator
- Java Tuition Calculator
- Java
- Javascript
- Javascript Assignment
- Java Exam
- You Will Complete C++ Code For A Tree-Based Data Structure For Storing A Collection Of Strings
- Rent Estimate Model
- C++ Computer Programming Assignment
- Python Assignment
- Website Login / Registration Application
- Analyzing Data (Indices Of Countries) , Using Correlation , Covariance , Portfolio Theory Optimization Method.
- Writer Choice
- Application Security Homework
- Small Java Assignment
- Polynomials
- Pretty Easy R Program Assignment
- Database Design Project
- Create An Application To Manage A Shopping Site: Visual Studio C# Console App (.Net Core)
- Programming Assignment 4-1 And 4-2
- Project 2 Needed Done By Thursday
- Using Deep Learning To Train A Program To Detect Wether The Images Shows Signs Of Breast Cancer Or Not
- Need Help In R Program Hw
- C++ (Structs) Can You Help Me To Do My Lab Homework?
- Champion Wave
- Code Dots And Boxes With Instructions Provided By 11:30 Pm Pst Tonight.
- Php Homework
- Pointer To String
- C Coding Casino Assignment
- C Coding Casino Assignment
- Python Class With 6 Exercises To Be Completed Within 3 Hours
- Javafx Guis
- Using File To Translate Message- Entry Level Class
- Writing A C Code To Do Multiple Interactions Within An Attached File.
- Intro To Data Science (2 Multi-Part Questions)
- Java Programming Assignment
- Create A Tictactoe Game Using Java Programming
- Javascript Speed Writing Game Assignment
- Need Help In R Programming Class (Bio Statistics)
- Basic C++ Socket Programming Assignment
- Smtp Protocol