CMake Changes

This is the changes made by Patrick Plenefisch converting the native
code to use CMake and the CMake Maven Plugin, as opposed to the
native Maven plugin. This is to allow for compatibility with newer
versions of the GCC toolchain. All the cpp sources were moved from
maven style directories to cpp style directories for CMake.

Change-Id: I67f5e3608948f37c83b0990d232105a3784f8593
This commit is contained in:
Brad Miller
2014-03-24 16:13:08 -04:00
parent 33134bef1d
commit 69d9ad70ab
804 changed files with 586 additions and 9377 deletions

View File

@@ -0,0 +1,43 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "mocks/networktables2/NetworkTableEntry.h"
#include "mocks/networktables2/MockServerConnectionAdapter.h"
#include "networktables2/server/ServerConnectionList.h"
using namespace testing;
TEST(ConnectionListTests, testSendTransaction) {
MockServerConnectionAdapter* adapter1 = new MockServerConnectionAdapter();
MockServerConnectionAdapter* adapter2 = new MockServerConnectionAdapter();
MockNetworkTableEntry* entry1 = new MockNetworkTableEntry();
MockNetworkTableEntry* entry2 = new MockNetworkTableEntry();
ServerConnectionList* connectionList = new ServerConnectionList();
connectionList->add(adapter1);
connectionList->add(adapter2);
context.checking(new Expectations() {{
oneOf(adapter1).offerOutgoingAssignment(entry1);
oneOf(adapter2).offerOutgoingAssignment(entry1);
}});
EXPECT_CALL(*adapter1, offerOutgoingAssignment(Pointee(entry1))
.Times(AtLeast(1)));
EXPECT_CALL(*adapter2, offerOutgoingAssignment(Pointee(entry1))
.Times(AtLeast(1)));
// EXPECT_CALL(*streamProvider, close())
// .Times(1);
// EXPECT_CALL(*thread1, stop())
// .Times(1);
// EXPECT_CALL(*thread2, stop())
// .Times(1);
// NetworkTableServer *server = new NetworkTableServer(*streamProvider, *(new NetworkTableEntryTypeManager()), *threadManager);
// server->close();
// delete threadManager;
// delete streamProvider;
// delete thread1;
// delete thread2;
}

View File

@@ -0,0 +1,22 @@
/*
* MockNetworkTableEntry.h
*
* Created on: Sep 26, 2012
* Author: Fred
*/
#ifndef MOCKNETWORKTABLEENTRY_H_
#define MOCKNETWORKTABLEENTRY_H_
#include "networktables2/NetworkTableEntry.h"
#include "gmock/gmock.h"
using namespace std;
class MockNetworkTableEntry : public NeworkTableEntry {
public:
MOCK_METHOD0(isDirty, void());
MOCK_METHOD1(makeDirty, void());
};
#endif /* MOCKNETWORKTABLEENTRY_H_ */

View File

@@ -0,0 +1,21 @@
/*
* MockOutgoingEntryReciever.h
*
* Created on: Sep 25, 2012
* Author: Fredric Silberberg
*/
#ifndef MOCKOUTGOINGENTRYRECEIVER_H_
#define MOCKOUTGOINGENTRYRECEIVER_H_
#include "gmock/gmock.h"
#include "networktables2/OutgoingEntryReceiver.h"
#include "networktables2/NetworkTableEntry.h"
class MockOutgoingEntryReceiver : public OutgoingEntryReceiver {
public:
MOCK_METHOD0(offerOutgoingAssignment, void(NetworkTableEntry& entry));
MOCK_METHOD1(offerOutgoingUpdate, void(NetworkTableEntry& entry));
};
#endif /* MOCKOUTGOINGENTRYRECEIVER_H_ */

View File

@@ -0,0 +1,88 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <string>
using ::testing::MakeMatcher;
using ::testing::Matcher;
using ::testing::MatcherInterface;
using ::testing::MatchResultListener;
class IsArrayEqualToMatcher : public MatcherInterface<const char*> {
public:
IsArrayEqualToMatcher(const char* _exp, int _expLen){
exp = _exp;
expLen = _expLen;
}
virtual bool MatchAndExplain(const char* arg, MatchResultListener* listener) const {
for(int i = 0; i<expLen; ++i){
if(exp[i]!=arg[i])
return false;
}
return true;
}
virtual void DescribeTo(::std::ostream* os) const {
*os << "is equal to array";
}
virtual void DescribeNegationTo(::std::ostream* os) const {
*os << "is not equal to array";
}
private:
const char* exp;
int expLen;
};
inline Matcher<const char*> IsArrayEqualTo(const char* exp, int expLen) {
return MakeMatcher(new IsArrayEqualToMatcher(exp, expLen));
}
TEST(std::string, EmptyAsciiString) {
std::string s("");
EXPECT_STREQ("", s.c_str());
char expA[1] = {0};
EXPECT_THAT(s.u_str(), IsArrayEqualTo(expA, 1));
EXPECT_EQ(0, s.length());
}
TEST(std::string, NonEmptyAsciiString) {
std::string s("Hello");
EXPECT_STREQ("Hello", s.c_str());
char expA[6] = {'H', 'e', 'l', 'l', 'o', 0};
EXPECT_THAT(s.u_str(), IsArrayEqualTo(expA, 6));
EXPECT_EQ(5, s.length());
}
TEST(std::string, EmptyUnicodeString) {
char inital[1] = {0};
std::string s(inital);
EXPECT_STREQ("", s.c_str());
char expA[1] = {0};
EXPECT_THAT(s.u_str(), IsArrayEqualTo(expA, 1));
EXPECT_EQ(0, s.length());
}
TEST(std::string, NonEmptyUnicodeString) {
char inital[5] = {'T', 'e', 's', 't', 0};
std::string s(inital);
EXPECT_STREQ("Test", s.c_str());
char expA[5] = {'T', 'e', 's', 't', 0};
EXPECT_THAT(s.u_str(), IsArrayEqualTo(expA, 5));
EXPECT_EQ(4, s.length());
}
TEST(std::string, NonAsciiString) {
char inital[6] = {'T', 'e', 's', 500, 't', 0};
std::string s(inital);
EXPECT_THROW(s.c_str(), UnicodeStringException);
char expA[6] = {'T', 'e', 's', 500, 't', 0};
EXPECT_THAT(s.u_str(), IsArrayEqualTo(expA, 6));
EXPECT_EQ(5, s.length());
}