113465Sgabeblack@google.com/* 213465Sgabeblack@google.com * Copyright (c) 2012, 2018 ARM Limited 313465Sgabeblack@google.com * All rights reserved 413465Sgabeblack@google.com * 513465Sgabeblack@google.com * The license below extends only to copyright in the software and shall 613465Sgabeblack@google.com * not be construed as granting a license to any other intellectual 713465Sgabeblack@google.com * property including but not limited to intellectual property relating 813465Sgabeblack@google.com * to a hardware implementation of the functionality of the software 913465Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1013465Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1113465Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1213465Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1313465Sgabeblack@google.com * 1413465Sgabeblack@google.com * Copyright (c) 2006 The Regents of The University of Michigan 1513465Sgabeblack@google.com * All rights reserved. 1613465Sgabeblack@google.com * 1713465Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1813465Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1913465Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 2013465Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 2113465Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 2213465Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2313465Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2413465Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2513465Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2613465Sgabeblack@google.com * this software without specific prior written permission. 2713465Sgabeblack@google.com * 2813465Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2913465Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3013465Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3113465Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3213465Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3313465Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3413465Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3513465Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3613465Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3713465Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3813465Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3913465Sgabeblack@google.com * 4013465Sgabeblack@google.com * Authors: Ali Saidi 4113465Sgabeblack@google.com */ 4213465Sgabeblack@google.com 4313465Sgabeblack@google.com#include <gtest/gtest.h> 4413465Sgabeblack@google.com 4513465Sgabeblack@google.com#include "base/addr_range_map.hh" 4613465Sgabeblack@google.com 4713465Sgabeblack@google.com// Converted from legacy unit test framework 4813465Sgabeblack@google.comTEST(AddrRangeMapTest, LegacyTests) 4913465Sgabeblack@google.com{ 5013465Sgabeblack@google.com AddrRangeMap<int> r; 5113465Sgabeblack@google.com AddrRangeMap<int>::const_iterator i; 5213465Sgabeblack@google.com 5313465Sgabeblack@google.com i = r.insert(RangeIn(10, 40), 5); 5413465Sgabeblack@google.com ASSERT_NE(i, r.end()); 5513465Sgabeblack@google.com 5613465Sgabeblack@google.com i = r.insert(RangeIn(60, 90), 3); 5713465Sgabeblack@google.com ASSERT_NE(i, r.end()); 5813465Sgabeblack@google.com 5913465Sgabeblack@google.com EXPECT_NE(r.intersects(RangeIn(20, 30)), r.end()); 6013465Sgabeblack@google.com EXPECT_EQ(r.contains(RangeIn(55, 55)), r.end()); 6113465Sgabeblack@google.com EXPECT_EQ(r.intersects(RangeIn(55, 55)), r.end()); 6213465Sgabeblack@google.com 6313465Sgabeblack@google.com i = r.insert(RangeIn(0, 12), 1); 6413465Sgabeblack@google.com EXPECT_EQ(i, r.end()); 6513465Sgabeblack@google.com 6613465Sgabeblack@google.com i = r.insert(RangeIn(0, 9), 1); 6713465Sgabeblack@google.com ASSERT_NE(i, r.end()); 6813465Sgabeblack@google.com 6913465Sgabeblack@google.com EXPECT_NE(r.contains(RangeIn(20, 30)), r.end()); 7013465Sgabeblack@google.com} 71