Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Macros | Functions | Variables
0.new.cpp File Reference
#include <new>
#include <cstddef>
#include <setjmp.h>
#include <signal.h>
#include <rw_new.h>
#include <rw_driver.h>
Include dependency graph for 0.new.cpp:

Go to the source code of this file.

Macros

#define FAIL(code)
 
#define PASS(code)
 
#define CATCH(code)
 
#define NOTHROW(code)
 
#define LEAK(code, bytes, blks)
 
#define TEST(name)
 

Functions

void test_new_delete ()
 
void test_bad_alloc ()
 
void test_mismatch ()
 
void test_bad_delete ()
 
void test_double_delete ()
 
void test_corruption ()
 
void test_leaks ()
 
void test_stress ()
 
int run_test (int, char **)
 
int main (int argc, char **argv)
 

Variables

int exit_status
 
volatile int line
 
volatile int fail
 
jmp_buf env
 

Macro Definition Documentation

◆ CATCH

#define CATCH (   code)
Value:
try { code; fail = 1; } \
catch (_RWSTD_BAD_ALLOC) { fail = 0; } \
catch (...) { fail = 2; } \
rw_assert (!fail, __FILE__, __LINE__, \
"%s", 1 == fail ? "failed to throw" : \
"threw an unknown exception")
volatile int fail
Definition 0.new.cpp:47
#define _RWSTD_BAD_ALLOC
Definition rw_new.h:141

Definition at line 121 of file 0.new.cpp.

◆ FAIL

#define FAIL (   code)
Value:
fail = line = __LINE__; \
signal (SIGABRT, handle_ABRT); \
if (0 == setjmp (env)) { \
code; \
exit_status = 1; \
rw_assert (0, __FILE__, line, "expected assertion"); \
} \
else \
(void)0
volatile int line
Definition 0.new.cpp:46
int exit_status
Definition 0.new.cpp:42
jmp_buf env
Definition 0.new.cpp:49
#define setjmp
Definition _csetjmp.h:52
#define SIGABRT

Definition at line 61 of file 0.new.cpp.

◆ LEAK

#define LEAK (   code,
  bytes,
  blks 
)
Value:
do { \
/* establish a checkpoint for memory leaks */ \
rwt_check_leaks (0, 0); \
\
code; \
\
/* find memory leaks since the last checkpoint */ \
std::size_t nbytes; \
const std::size_t nblocks = rwt_check_leaks (&nbytes, 0); \
\
rw_assert (blks == nblocks && bytes == nbytes, \
__FILE__, __LINE__, \
"failed to detect a leak of %d bytes in " \
"%d blocks: got %zu bytes in %zu blocks", \
bytes, blks, nbytes, nblocks); \
} while (0)
UChar bytes[sizeof(int)]
Definition printf.cpp:83
_TEST_EXPORT _RWSTD_SIZE_T rwt_check_leaks(_RWSTD_SIZE_T *, const rwt_free_store *)
Definition new.cpp:684

Definition at line 343 of file 0.new.cpp.

◆ NOTHROW

#define NOTHROW (   code)
Value:
try { fail = 0; code; } \
catch (...) { fail = 1; } \
rw_assert (!fail, __FILE__, __LINE__, \
"unexpected exception")

Definition at line 129 of file 0.new.cpp.

◆ PASS

#define PASS (   code)
Value:
fail = -1; line = __LINE__; \
signal (SIGABRT, handle_ABRT); \
if (0 == setjmp (env)) { \
code; \
} \
else if (fail != line) { \
exit_status = 1; \
rw_assert (0, __FILE__, line, "unexpected assertion"); \
} (void)0

Definition at line 72 of file 0.new.cpp.

◆ TEST

#define TEST (   name)
Value:
if (rw_opt_no_ ## name) \
rw_note (0, 0, __LINE__, "%s test disabled", #name); \
else \
test_ ## name ()
const char * name
Definition codecvt1.cpp:72

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 502 of file 0.new.cpp.

◆ run_test()

int run_test ( int  ,
char **   
)

Definition at line 468 of file 0.new.cpp.

◆ test_bad_alloc()

void test_bad_alloc ( )

Definition at line 135 of file 0.new.cpp.

◆ test_bad_delete()

void test_bad_delete ( )

Definition at line 251 of file 0.new.cpp.

◆ test_corruption()

void test_corruption ( )

Definition at line 314 of file 0.new.cpp.

◆ test_double_delete()

void test_double_delete ( )

Definition at line 289 of file 0.new.cpp.

◆ test_leaks()

void test_leaks ( )

Definition at line 362 of file 0.new.cpp.

◆ test_mismatch()

void test_mismatch ( )

Definition at line 219 of file 0.new.cpp.

◆ test_new_delete()

void test_new_delete ( )

Definition at line 85 of file 0.new.cpp.

◆ test_stress()

void test_stress ( )

Definition at line 403 of file 0.new.cpp.

Variable Documentation

◆ env

jmp_buf env

Definition at line 49 of file 0.new.cpp.

◆ exit_status

int exit_status

0.new.cpp - test exercising replacement operator new and delete

$Id$

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 1994-2008 Rogue Wave Software, Inc.

Definition at line 42 of file 0.new.cpp.

◆ fail

volatile int fail

Definition at line 47 of file 0.new.cpp.

◆ line

volatile int line

Definition at line 46 of file 0.new.cpp.