Ticket #2903: Bug_in_istarts_with.cpp

File Bug_in_istarts_with.cpp, 666 bytes (added by boris.glick@…, 14 years ago)

Code sample to demonstrate a bug. Compile with /Zc:wchar_t-

Line 
1// Bug_in_istarts_with.cpp : Defines the entry point for the console application.
2//
3
4#include "stdafx.h"
5#include <iostream>
6
7#include <boost/algorithm/string/predicate.hpp>
8
9int _tmain(int argc, _TCHAR* argv[])
10{
11 if(boost::algorithm::istarts_with(L"Prefix.FollowedByText", L"Prefix"))
12 {
13 std::cout << "Test succeeded" << std::endl;
14 }
15 else
16 {
17 // Fails if compiling with /Zc:wchar_t-
18 // (do not treat wchar_t as a built-in type)
19 // Reason for failure: boost::end() points past the terminating NULL character.
20 std::cout << "Test failed" << std::endl;
21 }
22
23 std::cout << "Press Enter to continue ";
24
25 getchar();
26
27 return 0;
28}
29