blob: d947ddd49ddafd8e73cb4a07b8184fdc2ce6b538 [file] [log] [blame]
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -08001// Copyright (c) 2009 The Chromium OS 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.
4
5#include <utility>
6#include <vector>
7#include <gtest/gtest.h>
8#include "update_engine/graph_utils.h"
9
10using std::make_pair;
11using std::vector;
12
13namespace chromeos_update_engine {
14
15class GraphUtilsTest : public ::testing::Test {};
16
17TEST(GraphUtilsTest, SimpleTest) {
18 Graph graph(2);
19
20 graph[0].out_edges.insert(make_pair(1, EdgeProperties()));
21
22 vector<Extent>& extents = graph[0].out_edges[1].extents;
23
24 EXPECT_EQ(0, extents.size());
25 graph_utils::AppendBlockToExtents(&extents, 0);
26 EXPECT_EQ(1, extents.size());
27 graph_utils::AppendBlockToExtents(&extents, 1);
28 graph_utils::AppendBlockToExtents(&extents, 2);
29 EXPECT_EQ(1, extents.size());
30 graph_utils::AppendBlockToExtents(&extents, 4);
31
32 EXPECT_EQ(2, extents.size());
33 EXPECT_EQ(0, extents[0].start_block());
34 EXPECT_EQ(3, extents[0].num_blocks());
35 EXPECT_EQ(4, extents[1].start_block());
36 EXPECT_EQ(1, extents[1].num_blocks());
37
38 EXPECT_EQ(4, graph_utils::EdgeWeight(graph, make_pair(0, 1)));
39}
40
41} // namespace chromeos_update_engine