Author: mturk Date: Mon Apr 13 07:45:47 2009 New Revision: 764368 URL: http://svn.apache.org/viewvc?rev=764368&view=rev Log: Add native tests that gets compiled with --enable-test
Added: commons/sandbox/runtime/trunk/src/main/native/test/ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (with props) Added: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=764368&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Mon Apr 13 07:45:47 2009 @@ -0,0 +1,86 @@ +/* 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. + */ + +#include "acr.h" +#include "acr_private.h" +#include "acr_arch.h" +#include "acr_error.h" +#include "acr_string.h" +#include "acr_memory.h" +#include "acr_vm.h" + + +/** + * Test cases + */ +ACR_JNI_EXPORT_DECLARE(void, TestPrivate, test000)(ACR_JNISTDARGS, jint err) +{ + ACR_ThrowException(_E, THROW_FMARK, ACR_EX_EGENERAL, err); +} + +ACR_JNI_EXPORT_DECLARE(void, TestPrivate, test001)(ACR_JNISTDARGS, jstring msg) +{ + CSTR_GETCHAR(msg); + ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EINVAL, J2S(msg)); + CSTR_RELEASE(msg); +} + +ACR_JNI_EXPORT_DECLARE(void, TestPrivate, test002)(ACR_JNISTDARGS, jint err) +{ + ACR_ThrowException(NULL, THROW_FMARK, ACR_EX_ENOMEM, err); +} + +ACR_JNI_EXPORT_DECLARE(void, TestPrivate, test003)(ACR_JNISTDARGS, jint d) +{ + ACR_Free(NULL, THROW_FMARK, NULL); +} + +ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test004)(ACR_JNISTDARGS, jint d) +{ + int i, j; + + for (i = 0; i < 10; i++) { + acr_sbh_t *sbh = ACR_SbhCreate(_E, THROW_FMARK, NULL, d); + if (!sbh) + break; + for (j = 0; j < 10000; j++) { + void *m = ACR_SbhMalloc(_E, THROW_FMARK, sbh, j + 1); + if (!m) + return i; + } + ACR_SbhDestroy(_E, THROW_FMARK, sbh); + } + return i; +} + +ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test005)(ACR_JNISTDARGS, jstring s) +{ + WSTR_GETCHAR(s); + WSTR_DOALLOC(s); + WSTR_RELEASE(s); + + return W2L(s); +} + +ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test006)(ACR_JNISTDARGS, jstring s) +{ + jint l; + CSTR_GETCHAR(s); + + l = (jint)strlen(J2S(s)); + CSTR_RELEASE(s); + return l; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c ------------------------------------------------------------------------------ svn:eol-style = native