add a use_alsa gyp setting
[chromium-blink-merge.git] / courgette / ensemble_unittest.cc
blobd35622fffda6ca7adaf490493094aab0d7c70618
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "courgette/base_test_unittest.h"
6 #include "courgette/courgette.h"
7 #include "courgette/streams.h"
9 class EnsembleTest : public BaseTest {
10 public:
12 void TestEnsemble(std::string src_bytes, std::string tgt_bytes) const;
14 void PeEnsemble() const;
17 void EnsembleTest::TestEnsemble(std::string src_bytes,
18 std::string tgt_bytes) const {
20 courgette::SourceStream source;
21 courgette::SourceStream target;
23 source.Init(src_bytes);
24 target.Init(tgt_bytes);
26 courgette::SinkStream patch_sink;
28 courgette::Status status;
30 status = courgette::GenerateEnsemblePatch(&source, &target, &patch_sink);
31 EXPECT_EQ(courgette::C_OK, status);
33 courgette::SourceStream patch_source;
34 patch_source.Init(patch_sink.Buffer(), patch_sink.Length());
36 courgette::SinkStream patch_result;
38 status = courgette::ApplyEnsemblePatch(&source, &patch_source, &patch_result);
39 EXPECT_EQ(courgette::C_OK, status);
41 EXPECT_EQ(target.OriginalLength(), patch_result.Length());
42 EXPECT_FALSE(memcmp(target.Buffer(),
43 patch_result.Buffer(),
44 target.OriginalLength()));
47 void EnsembleTest::PeEnsemble() const {
48 std::list<std::string> src_ensemble;
49 std::list<std::string> tgt_ensemble;
51 src_ensemble.push_back("en-US.dll");
52 src_ensemble.push_back("setup1.exe");
53 src_ensemble.push_back("elf-32-1");
54 src_ensemble.push_back("pe-64.exe");
56 tgt_ensemble.push_back("en-US.dll");
57 tgt_ensemble.push_back("setup2.exe");
58 tgt_ensemble.push_back("elf-32-2");
59 tgt_ensemble.push_back("pe-64.exe");
61 std::string src_bytes = FilesContents(src_ensemble);
62 std::string tgt_bytes = FilesContents(tgt_ensemble);
64 src_bytes = "aaabbbccc" + src_bytes + "dddeeefff";
65 tgt_bytes = "aaagggccc" + tgt_bytes + "dddeeefff";
67 TestEnsemble(src_bytes, tgt_bytes);
70 TEST_F(EnsembleTest, DISABLED_All) {
71 // TODO(dgarrett) http://code.google.com/p/chromium/issues/detail?id=101614
72 PeEnsemble();