aboutsummaryrefslogtreecommitdiff
path: root/samples/ppm_test.cc
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2019-03-18 07:35:29 -0700
committerGitHub <noreply@github.com>2019-03-18 07:35:29 -0700
commit60f04069c0967703e1260db2bf6133a44002f92a (patch)
tree5e10f4512f2928aa034843cd27b8f1163544e6ae /samples/ppm_test.cc
parent6064a402932975f3d359b9798bc156886f6b18e8 (diff)
downloadamber-60f04069c0967703e1260db2bf6133a44002f92a.tar.gz
Integrate PPM unit tests. (#379)
This Cl integrates the PPM test into the test suite. Part of this work involved updating the conversion code to return a vector<uint8_t> instead of a std::string.
Diffstat (limited to 'samples/ppm_test.cc')
-rw-r--r--samples/ppm_test.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/samples/ppm_test.cc b/samples/ppm_test.cc
index 9821455..7a695af 100644
--- a/samples/ppm_test.cc
+++ b/samples/ppm_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ppm.h"
+#include "samples/ppm.h"
#include <algorithm>
#include <cstring>
@@ -28,30 +28,30 @@ namespace {
const uint8_t kExpectedPPM[] = {
0x50, 0x36, 0x0a, 0x31, 0x32, 0x20, 0x36, 0x0a, 0x32, 0x35, 0x35, 0x0a,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff,
- 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
- 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff,
- 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff};
} // namespace
-using PpmTest = testing::Test;
+using PPMTest = testing::Test;
-TEST_F(PpmTest, ConvertToPPM) {
+TEST_F(PPMTest, ConvertToPPM) {
const uint32_t width = 12;
const uint32_t height = 6;
@@ -75,20 +75,17 @@ TEST_F(PpmTest, ConvertToPPM) {
// reset alpha to 1
pixel |= MaskAplha;
}
+ Value v;
v.SetIntValue(static_cast<uint64_t>(pixel));
data.push_back(v);
}
}
- amber::Result r;
- std::string image;
- std::tie(r, image) = ConvertToPPM(width, height, &data);
+ std::vector<uint8_t> out_buf;
+ ppm::ConvertToPPM(width, height, data, &out_buf);
- EXPECT_TRUE(r.IsSuccess());
-
- // Compare
- EXPECT_EQ(image.size(), sizeof(kExpectedPPM));
- EXPECT_EQ(std::memcmp(image.c_str(), kExpectedPPM, sizeof(kExpectedPPM)), 0);
+ EXPECT_EQ(out_buf.size(), sizeof(kExpectedPPM));
+ EXPECT_EQ(std::memcmp(out_buf.data(), kExpectedPPM, sizeof(kExpectedPPM)), 0);
}
} // namespace amber