Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing #27

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
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
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@

sudo: false
sudo: true
language: cpp
compiler:
- gcc
os:
- linux
before_install:
- sudo apt-add-repository ppa:bruun/hayai -y
- sudo apt-get update
- sudo apt-get install libhayai-dev
install:
- CURRENT=`pwd`
- sudo apt-get install libgtest-dev
- cd /usr/src/gtest
- sudo cmake CMakeLists.txt
- sudo make
- sudo cp *.a /usr/lib
- cd $CURRENT
#before_script:
#- sudo apt-get install valgrind
script:
- cmake .
- make all
- cd test && ctest .

6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ set (CPPROUTE4ME_VERSION_MINOR 0)

# Checking for dependencies
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(GTest REQUIRED)

# Set up include pathes
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CPPROUTE4ME_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})

# Set up output paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

# Set up source directories
ADD_SUBDIRECTORY(src bin)
ADD_SUBDIRECTORY(test test)
ADD_SUBDIRECTORY(examples examples)
ADD_SUBDIRECTORY(test test)
ADD_SUBDIRECTORY(benchmarks benchmarks)
31 changes: 31 additions & 0 deletions benchmarks/ActivitiesBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(ActivitiesFixture, ActivitiesTest, 10, 10)
{
pRoute->get_all_activities();
}

BENCHMARK(ActivitiesFixture, ActivitiesByTeam, 10, 10)
{
const char *route_id = "CA902292134DBC134EAF8363426BD247";
pRoute->get_team_activities(route_id);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
31 changes: 31 additions & 0 deletions benchmarks/AddressBookBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(AddressBookFixture, GetAllContacts, 10, 10)
{
pRoute->get_address_book_contacts();
}

BENCHMARK(AddressBookFixture, GetOneContact, 10, 10)
{
const char *id = "Wall";
int ret = pRoute->get_address_book_contacts_by_text(id);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
25 changes: 25 additions & 0 deletions benchmarks/AvoidanceZonesBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(AvoidanceZonesFixture, GetAllZones, 10, 10)
{
pRoute->get_avoidance_zones();
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
42 changes: 42 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

ADD_EXECUTABLE(ActivitiesBenchmark ActivitiesBenchmark.cpp)
TARGET_LINK_LIBRARIES(ActivitiesBenchmark route4me)

ADD_EXECUTABLE(OptimizationBenchmark OptimizationBenchmark.cpp)
TARGET_LINK_LIBRARIES(OptimizationBenchmark route4me)

ADD_EXECUTABLE(AddressBookBenchmark AddressBookBenchmark.cpp)
TARGET_LINK_LIBRARIES(AddressBookBenchmark route4me)

ADD_EXECUTABLE(ConfigBenchmark ConfigBenchmark.cpp)
TARGET_LINK_LIBRARIES(ConfigBenchmark route4me)

ADD_EXECUTABLE(GeocoderBenchmark GeocoderBenchmark.cpp)
TARGET_LINK_LIBRARIES(GeocoderBenchmark route4me)

ADD_EXECUTABLE(GPSBenchmark GPSBenchmark.cpp)
TARGET_LINK_LIBRARIES(GPSBenchmark route4me)

ADD_EXECUTABLE(NotesBenchmark NotesBenchmark.cpp)
TARGET_LINK_LIBRARIES(NotesBenchmark route4me)

ADD_EXECUTABLE(OrdersBenchmark OrdersBenchmark.cpp)
TARGET_LINK_LIBRARIES(OrdersBenchmark route4me)

ADD_EXECUTABLE(RoutesBenchmark RoutesBenchmark.cpp)
TARGET_LINK_LIBRARIES(RoutesBenchmark route4me)

ADD_EXECUTABLE(SessionBenchmark SessionBenchmark.cpp)
TARGET_LINK_LIBRARIES(SessionBenchmark route4me)

ADD_EXECUTABLE(StreetsBenchmark StreetsBenchmark.cpp)
TARGET_LINK_LIBRARIES(StreetsBenchmark route4me)

ADD_EXECUTABLE(TerritoriesBenchmark TerritoriesBenchmark.cpp)
TARGET_LINK_LIBRARIES(TerritoriesBenchmark route4me)

ADD_EXECUTABLE(TrackingBenchmark TrackingBenchmark.cpp)
TARGET_LINK_LIBRARIES(TrackingBenchmark route4me)

ADD_EXECUTABLE(UsersBenchmark UsersBenchmark.cpp)
TARGET_LINK_LIBRARIES(UsersBenchmark route4me)
25 changes: 25 additions & 0 deletions benchmarks/ConfigBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(ConfigFixture, GetAllConfigs, 10, 10)
{
pRoute->get_config();
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
36 changes: 36 additions & 0 deletions benchmarks/GPSBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(GPSFixture, Set, 10, 10)
{
Json::Value params(Json::objectValue);
params["route_id"] = "AC16E7D338B551013FF34266FE81A5EE";
params["format"] = CRoute4Me::Csv;
params["lat"] = 33.14384;
params["lng"] = -83.22466;
params["course"] = 1;
params["speed"] = 120;
params["device_type"] = CRoute4Me::IPhone;
params["device_guid"] = "TEST_GPS";
params["device_timestamp"] = "2014-06-14 17:43:35";
params["member_id"] = 1;
int ret = pRoute->set_gps(params);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
34 changes: 34 additions & 0 deletions benchmarks/GeocoderBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(GeocoderFixture, BatchGeocoding, 10, 10)
{
const char* addrs = "Los20%Angeles20%International20%Airport,20%CA";
const char* format = "json";
int ret = pRoute->batch_geocoding(addrs, format);
}

BENCHMARK(GeocoderFixture, ReverseGeocoding, 10, 10)
{
const char* addrs = "33.945705,-118.391105";
const char* format = "json";
int ret = pRoute->reverse_geocoding(addrs, format);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
27 changes: 27 additions & 0 deletions benchmarks/NotesBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(AddressBookFixture, GetAllContacts, 10, 10)
{
const char *route_id = "CA902292134DBC134EAF8363426BD247";
const char *route_destination_id = "174405709A";
pRoute->get_route_notes(route_id, route_destination_id);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
32 changes: 32 additions & 0 deletions benchmarks/OptimizationBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(OptimizationFixture, GetOptimization, 10, 10)
{
const char *id = "2FB5F91365317758045DB9F19DF5A522";
pRoute->get_optimization(id);
}

BENCHMARK(OptimizationFixture, Reoptimize, 10, 10)
{
const char *id = "c46648541ca5d716a31ffae6f405a37d";
int ret = pRoute->reoptimize(id);
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
25 changes: 25 additions & 0 deletions benchmarks/OrdersBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <hayai/hayai.hpp>
#include <route4me.h>

#define KEY "11111111111111111111111111111111"

CRoute4Me* pRoute;

BENCHMARK(OrdersFixture, GetAllOrders, 10, 10)
{
pRoute->get_all_orders();
}

int main()
{
CRoute4Me::init();
pRoute = new CRoute4Me(KEY);

hayai::ConsoleOutputter consoleOutputter;

hayai::Benchmarker::AddOutputter(consoleOutputter);
hayai::Benchmarker::RunAllTests();

pRoute->cleanup();
return 0;
}
Loading