wcht7.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 30 行

CPP
30
字号
#include <wchash.h>
#include <iostream.h>
#include "strdata.h"

#define test_except( code, except, string )			\
    try{							\
	code;							\
	cout << "Did not throw except\n";			\
    } catch( WCExcept::failure oops ) {			\
        WCExcept::wc_state cause = oops.cause();	\
        if( cause & WCExcept::except ) {			\
            cout << string << " (supposed to happen)\n";	\
        } else {						\
	    cout << "wrong except\n";				\
	}							\
    }

int main() {
    WCValHashSet<str_data> hash( str_data::hash_fn, 0 );
    hash.exceptions( WCExcept::check_all );
    str_data s = "hello";

    if( hash.buckets() == 0 ) cout << "Buckets should not be 0!!\n";
    hash.insert( s );
    test_except( hash.insert( s ), not_unique, "1" );
    test_except( hash.resize( 0 ), zero_buckets, "2" );
    hash.clear();
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?