-
Notifications
You must be signed in to change notification settings - Fork 836
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
Added GMock to UT project compilation #1902
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
// Copyright 2019 David Conran | ||
#include <gtest/gtest.h> | ||
#include <gmock/gmock.h> | ||
#include "ir_Argo.h" | ||
#include "IRac.h" | ||
#include "IRrecv.h" | ||
#include "IRrecv_test.h" | ||
#include "IRsend.h" | ||
#include "IRsend_test.h" | ||
#include "gtest/gtest.h" | ||
|
||
|
||
TEST(TestArgoACClass, toCommon) { | ||
|
@@ -50,9 +51,11 @@ TEST(TestArgoACClass, MessageConstructon) { | |
ac.setNight(true); | ||
|
||
// Don't implicitly trust this. It's just a guess. | ||
uint8_t expected[kArgoStateLength] = { | ||
0xAC, 0xF5, 0x00, 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0xAC, 0xD6, 0x01}; | ||
EXPECT_STATE_EQ(expected, ac.getRaw(), kArgoBits); | ||
auto expected = std::vector<uint8_t>({ | ||
0xAC, 0xF5, 0x00, 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0xAC, 0xD6, 0x01}); | ||
auto actual = ac.getRaw(); | ||
EXPECT_THAT(std::vector<uint8_t>(actual, actual + kArgoBits / 8), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is mostly to prove out that CI links w/ GMock correctly. The wrapping into vector is there, mostly to include readability (I don't believe the extra copy for UT hurts anything).
Anyways, this is mostly a sample to prove integration works. As long as the i-face is a C-Style array, use of fancy matchers doesn't bring much benefit (but they start to shine once STL containers get used) |
||
::testing::ElementsAreArray(expected)); | ||
EXPECT_EQ( | ||
"Power: On, Mode: 0 (Cool), Fan: 0 (Auto), Temp: 20C, Room Temp: 21C, " | ||
"Max: On, IFeel: On, Night: On", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is possible to use wildcard rules here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, though these "GMock" Makefile receipes are fairly generic and written this way.
See https://github.com/ceph/gmock/blob/master/make/Makefile for example