📄 vectortest.cc
字号:
// -*- c-basic-offset: 4 -*-/* * vectortest.{cc,hh} -- regression test element for Vector * Eddie Kohler * * Copyright (c) 2004 Regents of the University of California * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, subject to the conditions * listed in the Click LICENSE file. These conditions include: you must * preserve this copyright notice, and you cannot mention the copyright * holders in advertising related to the Software without their permission. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This * notice is a summary of the Click LICENSE file; the license in that file is * legally binding. */#include <click/config.h>#include "vectortest.hh"#include <click/vector.hh>#include <click/error.hh>#if CLICK_USERLEVEL# include <sys/time.h># include <sys/resource.h># include <unistd.h>#endifCLICK_DECLSVectorTest::VectorTest(){}VectorTest::~VectorTest(){}#define CHECK(x) if (!(x)) return errh->error("%s:%d: test `%s' failed", __FILE__, __LINE__, #x);intVectorTest::initialize(ErrorHandler *errh){ Vector<int> v; v.push_back(0); v.push_back(1); v.push_back(2); v.push_back(4); CHECK(v.size() == 4); Vector<int>::iterator i = v.insert(v.end() - 1, 3); CHECK(i - v.begin() == 3); CHECK(*i == 3); CHECK(v.size() == 5 && v[0] == 0 && v[1] == 1 && v[2] == 2 && v[4] == 4); i = v.insert(v.end(), 5); CHECK(i == v.end() - 1); CHECK(*i == 5); CHECK(v.back() == 5); errh->message("All tests pass!"); return 0;}EXPORT_ELEMENT(VectorTest)#include <click/vector.cc>CLICK_ENDDECLS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -