diff --git a/Makefile b/Makefile deleted file mode 100644 index c58946f9..00000000 --- a/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# -*- mode: python; -*- - -# This should be a Makefile, but it's not. - -# cc_library(name = "btree", -# srcs = [ "btree.h", -# "btree_container.h", -# "btree_map.h", -# "btree_set.h", -# "safe_btree.h", -# "safe_btree_map.h", -# "safe_btree_set.h" ], -# deps = [ "//strings", -# "//strings:cord" ]) - -# cc_library(name = "btree_test_flags", -# srcs = [ "btree_test_flags.cc" ], -# deps = [ "//base" ]) - -# cc_binary(name = "btree_bench", -# srcs = [ "btree_bench.cc" ], -# deps = [ ":btree", -# ":btree_test_flags", -# "//testing/base", -# "//util/random" ]) - -# cc_test(name = "btree_test", -# srcs = [ "btree_test.cc", ], -# deps = [ ":btree", -# ":btree_test_flags", -# "//base:heapcheck", -# "//testing/base", -# "//util/random", -# ], -# size = "large") - -# cc_test(name = "safe_btree_test", -# srcs = [ "safe_btree_test.cc", ], -# deps = [ ":btree", -# ":btree_test_flags", -# "//base:heapcheck", -# "//testing/base", -# "//util/random", -# ], -# size = "large") - -# cc_fake_binary(name = "btree_nc", -# srcs = [ "btree_nc.cc" ], -# deps = [ ":btree" ], -# legacy = 0) - -# py_test(name = "btree_nc_test", -# srcs = [ "btree_nc_test.py" ], -# deps = [ "//pyglib", -# "//testing/pybase" ], -# data = [ "btree_nc" ], -# size = "large") - -# cc_binary(name = "btree_test_program", -# srcs = [ "btree_test_program.cc" ], -# deps = [ ":btree", -# "//devtools/gdb/component:gdb_test_utils" ], -# testonly = 1) - -# # This test will only actually test the pretty-printing code if it's -# # compiled with debug information (blaze build -c dbg). The default -# # mode, fastbuild, will pass but will not catch any regressions! -# py_test(name = "btree_printer_test", -# size = "large", -# srcs = [ "btree_printer_test.py", -# "btree_printer.py" ], -# deps = [ "//devtools/gdb/component:gdbpy", -# "//testing/pybase", -# "//testing/gdb:gdb_script_test_util", -# ":btree_test_program" ]) diff --git a/btree_nc.cc b/btree_nc.cc deleted file mode 100644 index 0a6ef512..00000000 --- a/btree_nc.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2009 Google Inc. All Rights Reserved. -// Author: jmacd@google.com (Josh MacDonald) - -#include "util/btree/btree_set.h" - -namespace { - -template -struct Compare { - R operator()(int a, int b) const { return reinterpret_cast(a < b); } -}; - -template -struct CompareTo : public util::btree::btree_key_compare_to_tag { - R operator()(int a, int b) const { return reinterpret_cast(a < b); } -}; - -#define TEST_COMPARE(r) \ - void TestCompile() { \ - util::btree::btree_set > s; \ - } - -#define TEST_COMPARE_TO(r) \ - void TestCompile() { \ - util::btree::btree_set > s; \ - } - -#if defined(TEST_bool) -TEST_COMPARE(bool); -#elif defined(TEST_int) -TEST_COMPARE(int); -#elif defined(TEST_float) -TEST_COMPARE(float); -#elif defined(TEST_pointer) -TEST_COMPARE(void*); -#elif defined(TEST_compare_to_bool) -TEST_COMPARE_TO(bool); -#elif defined(TEST_compare_to_int) -TEST_COMPARE_TO(int); -#elif defined(TEST_compare_to_float) -TEST_COMPARE_TO(float); -#elif defined(TEST_compare_to_pointer) -TEST_COMPARE_TO(void*); -#elif defined(TEST_large_nodesize) -void LargeNode() { - // (1 << 20) with 8-byte values is 2^17 values per node, which - // overflows the uint16 of btree::node_type::base_fields. - util::btree::btree_set, std::allocator, 1 << 20> - large_node_set; -} -#endif - -} // namespace - -int main() { - return 1; -} diff --git a/btree_nc_test.py b/btree_nc_test.py deleted file mode 100755 index b2a83277..00000000 --- a/btree_nc_test.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python2.4 -# -# Copyright 2006 Google Inc. All Rights Reserved. - -"""Negative compilation unit test for btree.h. -""" - -__author__ = 'pmattis@google.com (Peter Mattis)' - -import os -from google3.testing.pybase import googletest -from google3.testing.pybase import fake_target_util -from google3.pyglib import flags - -_FLAGS = flags.FLAGS - - -class BtreeNegativeUnitTest(googletest.TestCase): - """Negative compilation tests for btree.h""" - - def testCompilerErrors(self): - """Runs a list of tests to verify that erroneous code leads to - expected compiler messages.""" - - # Defines a list of test specs, where each element is a tuple - # (test name, list of regexes for matching the compiler errors). - test_specs = [ - # Test that bool works as a return type for key comparison. - ('bool', None), # None means compilation should succeed. - - # Test that int does not work as a return type for key comparison. - ('int', - [r'key_comparison_function_must_return_bool']), - - # Test that float does not work as a return type for key comparison. - ('float', - [r'key_comparison_function_must_return_bool']), - - # Test that void* does not work as a return type for key comparison. - ('pointer', - [r'key_comparison_function_must_return_bool']), - - # Test that bool does not work as a return type for compare-to - # comparison. - ('compare_to_bool', - [r'key_comparison_function_must_return_bool']), - - # Test that int works as a return type for compare-to comparison. - ('compare_to_int', None), # None means compilation should succeed. - - # Test that float does not work as a return type for compare-to - # comparison. - ('compare_to_float', - [r'key_comparison_function_must_return_bool']), - - # Test that void* does not work as a return type for compare-to - # comparison. - ('compare_to_pointer', - [r'key_comparison_function_must_return_bool']), - - # Test that large node sizes do not compile. - ('large_nodesize', - [r'target_node_size_too_large']), - ] - - # Runs the list of tests. - fake_target_util.AssertCcCompilerErrors( - self, - 'google3/util/btree/btree_nc', # path to the fake target file. - 'btree_nc.o', # name of the target to build. - test_specs) - - -if __name__ == '__main__': - googletest.main() diff --git a/btree_printer.py b/btree_printer.py deleted file mode 100755 index 8f233401..00000000 --- a/btree_printer.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python2.4 -# Copyright 2011 Google Inc. All Rights Reserved. -# GDB support for pretty printing StringPiece. - -"""GDB pretty-printer for btrees.""" - -# This is a module provided by GDB. -# Ref: http://wiki/Main/Google3GDBScripts -import gdb -from google3.devtools.gdb.component import printing - - -class BaseBtreePrinter(object): - """btree pretty-printer, for util/btree.""" - - def __init__(self, typename, val): - self.typename = typename - self.val = val - - def display_hint(self): - return 'array' - - def _my_iter(self, node): - count = node['fields_']['count'] - if node['fields_']['leaf']: - for i in range(count): - key = node['fields_']['values'][i] - yield ('[item]', key) - else: - # recursive generators are annoying: we can't just recurse, we need - # to expand and yield the values. - for i in range(count+1): - child = node['fields_']['children'][i] - for v in self._my_iter(child.dereference()): - yield v - - def children(self): - if self.nelements() != 0: - return self._my_iter(self.val['root_']['data'].dereference()) - else: - return iter([]) - - def nelements(self): - if self.val['root_']['data'] != 0: - root_fields = self.val['root_']['data'].dereference()['fields_'] - if root_fields['leaf']: - return root_fields['count'] - else: - return root_fields['size'] - else: - return 0 - - def to_string(self): # pylint: disable-msg=C6409 - """GDB calls this to compute the pretty-printed form.""" - return '%s with %d elements' % (self.typename, self.nelements()) - - -class BtreePrinter(BaseBtreePrinter): - """btree<> pretty-printer, for util/btree.""" - - def __init__(self, val): - BaseBtreePrinter.__init__(self, 'btree', val) - - -class BtreeSetPrinter(BaseBtreePrinter): - """btree_set<> pretty-printer.""" - - def __init__(self, val): - BaseBtreePrinter.__init__(self, 'btree_set', val['tree_']) - - -class BtreeMultisetPrinter(BaseBtreePrinter): - """btree_multiset<> pretty-printer.""" - - def __init__(self, val): - BaseBtreePrinter.__init__(self, 'btree_multiset', val['tree_']) - - -class BaseBtreeMapPrinter(BaseBtreePrinter): - """btree maps pretty-printer.""" - - def __init__(self, typename, val): - BaseBtreePrinter.__init__(self, typename, val['tree_']) - - def display_hint(self): - return 'map' - - def _my_map_iter(self, g): - for (_, pair) in g: - yield ('[key]', pair['first']) - yield ('[value]', pair['second']) - - def children(self): - # we need to break apart the pairs and yield them separately - if self.nelements() != 0: - return self._my_map_iter(BaseBtreePrinter.children(self)) - else: - return iter([]) - - -class BtreeMapPrinter(BaseBtreeMapPrinter): - """btree_map<> pretty-printer.""" - - def __init__(self, val): - BaseBtreeMapPrinter.__init__(self, 'btree_map', val) - - -class BtreeMultimapPrinter(BaseBtreeMapPrinter): - """btree_multimap<> pretty-printer.""" - - def __init__(self, val): - BaseBtreeMapPrinter.__init__(self, 'btree_multimap', val) - - -if __name__ == '__main__': - printing.RegisterGoogle3ClassPrettyPrinter('util::btree::btree<.*>', - BtreePrinter) - printing.RegisterGoogle3ClassPrettyPrinter('util::btree::btree_set<.*>', - BtreeSetPrinter) - printing.RegisterGoogle3ClassPrettyPrinter('util::btree::btree_multiset<.*>', - BtreeMultisetPrinter) - printing.RegisterGoogle3ClassPrettyPrinter('util::btree::btree_map<.*>', - BtreeMapPrinter) - printing.RegisterGoogle3ClassPrettyPrinter('util::btree::btree_multimap<.*>', - BtreeMultimapPrinter) diff --git a/btree_printer_test.py b/btree_printer_test.py deleted file mode 100755 index 95bc351e..00000000 --- a/btree_printer_test.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python2.4 -# -# Copyright 2011 Google Inc. All Rights Reserved. - -"""Tests for btree_printer.py gdb pretty printer.""" - -__author__ = "leg@google.com (Lawrence Greenfield)" - -from google3.pyglib import flags -from google3.testing.gdb import gdb_script_test_util -from google3.testing.pybase import googletest - -FLAGS = flags.FLAGS - - -class BtreePrinterTest(gdb_script_test_util.TestCase): - def testBtreeSet(self): - self.InitSession("btree_set", - "util/btree/btree_test_program") - self.RunTo("StopHereForDebugger") - - self.SetOption("print elements", 20) - self.TestPrintOutputMatches("*empty_set", - """btree_set with 0 elements""") - self.TestPrintOutputMatches("*small_set", - """btree_set with 10 elements = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}""") - self.TestPrintOutputMatches("*small_multiset", - """btree_multiset with 10 elements = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4}""") - self.TestPrintOutputMatches("*big_set", - """btree_set with 80 elements = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19...}""") - - self.RunSession() - - def testBtreeMap(self): - self.InitSession("btree_set", - "util/btree/btree_test_program") - self.RunTo("StopHereForDebugger") - - self.SetOption("print elements", 30) - self.TestPrintOutputMatches("*empty_map", - """btree_map with 0 elements""") - self.TestPrintOutputMatches("*small_map", - """btree_map with 10 elements = { - \\[0\\] = 0, - \\[1\\] = 13, - \\[2\\] = 26, - \\[3\\] = 39, - \\[4\\] = 52, - \\[5\\] = 65, - \\[6\\] = 78, - \\[7\\] = 91, - \\[8\\] = 104, - \\[9\\] = 117 -}""") - self.TestPrintOutputMatches("*small_multimap", - """btree_multimap with 10 elements = { - \\[0\\] = 0, - \\[0\\] = 1, - \\[1\\] = 2, - \\[1\\] = 3, - \\[2\\] = 4, - \\[2\\] = 5, - \\[3\\] = 6, - \\[3\\] = 7, - \\[4\\] = 8, - \\[4\\] = 9 -}""") - self.TestPrintOutputMatches("*big_map", - """btree_map with 80 elements = { - \\[0\\] = 0, - \\[1\\] = 7, - \\[2\\] = 14, - \\[3\\] = 21, - \\[4\\] = 28, - \\[5\\] = 35, - \\[6\\] = 42, - \\[7\\] = 49, - \\[8\\] = 56, - \\[9\\] = 63, - \\[10\\] = 70, - \\[11\\] = 77, - \\[12\\] = 84, - \\[13\\] = 91, - \\[14\\] = 98 - ... -}""") - - self.RunSession() - - -if __name__ == "__main__": - googletest.main() diff --git a/btree_test_program.cc b/btree_test_program.cc deleted file mode 100644 index 0c2dcf88..00000000 --- a/btree_test_program.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// Author: leg@google.com (Lawrence Greenfield) - -#include "base/init_google.h" -#include "base/logging.h" -#include "devtools/gdb/component/gdb_test_utils.h" -#include "util/btree/btree_map.h" -#include "util/btree/btree_set.h" - -using util::btree::btree_set; -using util::btree::btree_multiset; -using util::btree::btree_map; -using util::btree::btree_multimap; - -static btree_set* empty_set; -static btree_set* small_set; -static btree_set* big_set; -static btree_multiset* small_multiset; - -static btree_map* empty_map; -static btree_map* small_map; -static btree_map* big_map; -static btree_multimap* small_multimap; - -static void SetupBtreeSets() { - empty_set = new btree_set; - small_set = new btree_set; - small_multiset = new btree_multiset; - big_set = new btree_set; - - for (int i = 0; i < 10; ++i) { - small_set->insert(i); - small_multiset->insert(i / 2); - } - - for (int i = 0; i < 80; ++i) { - big_set->insert(i); - } -} - -static void SetupBtreeMaps() { - empty_map = new btree_map; - small_map = new btree_map; - small_multimap = new btree_multimap; - big_map = new btree_map; - - for (int i = 0; i < 10; ++i) { - small_map->insert(make_pair(i, i * 13)); - small_multimap->insert(make_pair(i / 2, i)); - } - - for (int i = 0; i < 80; ++i) { - big_map->insert(make_pair(i, i * 7)); - } -} - -int main(int argc, char** argv) { - FLAGS_logtostderr = true; - InitGoogle(argv[0], &argc, &argv, true); - SetupBtreeSets(); - SetupBtreeMaps(); - StopHereForDebugger(); - return 0; -}