-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1a2971
commit bf7c5ec
Showing
19 changed files
with
93 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <cassert> | ||
#include <optional> | ||
#include <string> | ||
|
||
/* NewType para el numero de nivel del juego */ | ||
class NumNivelOpcional { | ||
private: | ||
const std::optional<int> valor; | ||
|
||
public: | ||
NumNivelOpcional() {} | ||
explicit NumNivelOpcional(int v) : valor(v) { // | ||
assert(valor > 0); | ||
} | ||
std::string to_string() const { // | ||
if (!valor) | ||
return "-"; | ||
return std::to_string(valor.value()); | ||
} | ||
int get_valor() const { // | ||
return valor.value(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "../shared_num_nivel.h" | ||
#include <gtest/gtest.h> | ||
|
||
TEST(NumNivelOpcional, SePuedeCrearSinArgumentos) { // | ||
const NumNivelOpcional num_nivel; | ||
} | ||
|
||
TEST(NumNivelOpcional, SePuedeCrearConArgumentos) { // | ||
const NumNivelOpcional num_nivel(1); | ||
} | ||
|
||
TEST(NumNivelOpcional, ToStringSinValorNumerico) { // | ||
const NumNivelOpcional num_nivel; | ||
ASSERT_EQ(num_nivel.to_string(), "-"); | ||
} | ||
|
||
TEST(NumNivelOpcional, ToStringConValorNumerico) { // | ||
const NumNivelOpcional num_nivel(1); | ||
ASSERT_EQ(num_nivel.to_string(), "1"); | ||
} | ||
|
||
TEST(NumNivelOpcional, ObtenerValorSinValorNumericoGeneraExcepcion) { // | ||
const NumNivelOpcional num_nivel; | ||
ASSERT_THROW(num_nivel.get_valor(), std::bad_optional_access); | ||
} | ||
|
||
TEST(NumNivelOpcional, ObtenerValorConValorNumerico) { // | ||
const NumNivelOpcional num_nivel(1); | ||
ASSERT_EQ(num_nivel.get_valor(), 1); | ||
} | ||
|
||
TEST(NumNivelOpcional, ManualTest) { // | ||
NumNivelOpcional num_nivel(1); | ||
NumNivelOpcional num_nivel_2(2); | ||
// SHOULD NOT COMPILE | ||
// num_nivel = num_nivel_2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters