Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app
build
.DS_Store
*.pro.user
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"

namespace {

const testing::internal::RelationToSourceCopy kCopy;
const testing::internal::RelationToSourceReference kReference;

}

namespace testing {
namespace internal {

Expand Down
4 changes: 2 additions & 2 deletions tdd_intro/cleanroom/cleanroom.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TEMPLATE = subdirs

SUBDIRS += \
chatclient
#SUBDIRS += \
# chatclient
4 changes: 2 additions & 2 deletions tdd_intro/gtest.pri
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../3rd_party/gtest/release/ -lgtest
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../3rd_party/gtest/debug/ -lgtest
else:unix:!macx: LIBS += -L$$OUT_PWD/../../3rd_party/gtest/ -lgtest
else:unix: LIBS += -L$$OUT_PWD/../../3rd_party/gtest/ -lgtest

INCLUDEPATH += $$PWD/3rd_party/gtest/googletest/include
DEPENDPATH += $$PWD/3rd_party/gtest/googletest/include
Expand All @@ -10,4 +10,4 @@ win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../3rd_
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../3rd_party/gtest/debug/libgtest.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../3rd_party/gtest/release/gtest.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../3rd_party/gtest/debug/gtest.lib
else:unix:!macx: PRE_TARGETDEPS += $$OUT_PWD/../../3rd_party/gtest/libgtest.a
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../3rd_party/gtest/libgtest.a
69 changes: 69 additions & 0 deletions tdd_intro/homework/02_ternary_numbers/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,72 @@ The last place in a ternary number is the 1's place. The second to last is the 3

If your language provides a method in the standard library to perform the conversion, pretend it doesn't exist and implement it yourself.
*/

#include <gtest/gtest.h>
#include <cmath>


int IntFromTernaryNumberString(const std::string& ternaryNumberString)
{
int result = 0;
for (size_t i = 0; i < ternaryNumberString.size(); ++i)
{
if (ternaryNumberString[i] < '0' || ternaryNumberString[i] > '2')
{
return 0;
}

size_t power = ternaryNumberString.size() - i - 1;
result += (ternaryNumberString[i] - '0') * std::pow(3, power);
}

return result;
}

TEST(IntFromTernaryNumberString, one)
{
EXPECT_EQ(1, IntFromTernaryNumberString("1"));
}

TEST(IntFromTernaryNumberString, two)
{
EXPECT_EQ(2, IntFromTernaryNumberString("2"));
}

TEST(IntFromTernaryNumberString, decimal3ForTernary10)
{
EXPECT_EQ(3, IntFromTernaryNumberString("10"));
}

TEST(IntFromTernaryNumberString, decimal6ForTernary20)
{
EXPECT_EQ(6, IntFromTernaryNumberString("20"));
}

TEST(IntFromTernaryNumberString, decimal9ForTernary100)
{
EXPECT_EQ(9, IntFromTernaryNumberString("100"));
}

TEST(IntFromTernaryNumberString, decimal4ForTernary11)
{
EXPECT_EQ(4, IntFromTernaryNumberString("11"));
}

TEST(IntFromTernaryNumberString, decimal13ForTernary111)
{
EXPECT_EQ(13, IntFromTernaryNumberString("111"));
}

TEST(IntFromTernaryNumberString, zeroForInvalidTernary)
{
EXPECT_EQ(0, IntFromTernaryNumberString("3"));
EXPECT_EQ(0, IntFromTernaryNumberString("13"));
EXPECT_EQ(0, IntFromTernaryNumberString("."));
}

TEST(IntFromTernaryNumberString, acceptance)
{
EXPECT_EQ(302, IntFromTernaryNumberString("102012"));
}

1 change: 1 addition & 0 deletions tdd_intro/homework/04_weather_client/04_weather_client.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(../../gmock.pri)
include(../../gtest.pri)

TEMPLATE = app
CONFIG += console c++11
Expand Down
2 changes: 2 additions & 0 deletions tdd_intro/homework/04_weather_client/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Each line means "<request>" : "<response>":
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#include <cmath>

struct Weather
{
short temperature = 0;
Expand Down
1 change: 1 addition & 0 deletions tdd_intro/homework/06_coffee/06_coffee.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include(../../gtest.pri)
include(../../gmock.pri)

TEMPLATE = app
Expand Down
4 changes: 2 additions & 2 deletions tdd_intro/homework/homework.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ SUBDIRS += \
02_ternary_numbers \
03_bank_ocr \
04_weather_client \
05_word_wrapp \
06_coffee
05_word_wrapp
# 06_coffee