test.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org//===----------------------------------------------------------------------===// 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// The LLVM Compiler Infrastructure 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// This file is dual licensed under the MIT and the University of Illinois Open 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Source Licenses. See LICENSE.TXT for details. 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org//===----------------------------------------------------------------------===// 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// <iterator> 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// reverse_iterator 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// requires HasGreater<Iter1, Iter2> 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// bool 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y); 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <iterator> 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <cassert> 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "../../../../iterators.h" 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtemplate <class It> 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtest(It l, It r, bool x) 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const std::reverse_iterator<It> r1(l); 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const std::reverse_iterator<It> r2(r); 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert((r1 <= r2) == x); 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint main() 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const char* s = "1234567890"; 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true); 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false); 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true); 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(s, s, true); 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(s, s+1, false); 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org test(s+1, s, true); 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org