初始化PHP-Xlswrite扩展
This commit is contained in:
11
library/libexpat/expat/tests/.gitignore
vendored
Normal file
11
library/libexpat/expat/tests/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*.log
|
||||
/*.trs
|
||||
/out
|
||||
/xmlconf
|
||||
/xmltest.log
|
||||
Makefile
|
||||
runtests
|
||||
runtestspp
|
||||
xmlts.zip
|
||||
XML-Test-Suite
|
||||
.libs
|
66
library/libexpat/expat/tests/Makefile.am
Normal file
66
library/libexpat/expat/tests/Makefile.am
Normal file
@ -0,0 +1,66 @@
|
||||
#
|
||||
# __ __ _
|
||||
# ___\ \/ /_ __ __ _| |_
|
||||
# / _ \\ /| '_ \ / _` | __|
|
||||
# | __// \| |_) | (_| | |_
|
||||
# \___/_/\_\ .__/ \__,_|\__|
|
||||
# |_| XML parser
|
||||
#
|
||||
# Copyright (c) 2017 Expat development team
|
||||
# Licensed under the MIT license:
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
# persons to whom the Software is furnished to do so, subject to the
|
||||
# following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
SUBDIRS = . benchmark
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/../lib
|
||||
|
||||
noinst_LIBRARIES = libruntests.a
|
||||
|
||||
check_PROGRAMS = runtests runtestspp
|
||||
TESTS = runtests runtestspp
|
||||
|
||||
# To support MinGW and Non-MinGW at the same time:
|
||||
LOG_DRIVER = $(srcdir)/../test-driver-wrapper.sh
|
||||
|
||||
libruntests_a_SOURCES = \
|
||||
chardata.c \
|
||||
structdata.c \
|
||||
memcheck.c \
|
||||
minicheck.c
|
||||
|
||||
runtests_SOURCES = \
|
||||
runtests.c
|
||||
|
||||
runtestspp_SOURCES = \
|
||||
runtestspp.cpp
|
||||
|
||||
runtests_LDADD = libruntests.a ../lib/libexpat.la
|
||||
runtestspp_LDADD = libruntests.a ../lib/libexpat.la
|
||||
|
||||
EXTRA_DIST = \
|
||||
chardata.h \
|
||||
structdata.h \
|
||||
minicheck.h \
|
||||
memcheck.h \
|
||||
README.txt \
|
||||
udiffer.py \
|
||||
xmltest.log.expected \
|
||||
xmltest.sh
|
13
library/libexpat/expat/tests/README.txt
Normal file
13
library/libexpat/expat/tests/README.txt
Normal file
@ -0,0 +1,13 @@
|
||||
This directory contains the (fledgling) test suite for Expat. The
|
||||
tests provide general unit testing and regression coverage. The tests
|
||||
are not expected to be useful examples of Expat usage; see the
|
||||
examples/ directory for that.
|
||||
|
||||
The Expat tests use a partial internal implementation of the "Check"
|
||||
unit testing framework for C. More information on Check can be found at:
|
||||
|
||||
http://check.sourceforge.net/
|
||||
|
||||
Expat must be built and, depending on platform, must be installed, before "make check" can be executed.
|
||||
|
||||
This test suite can all change in a later version.
|
1
library/libexpat/expat/tests/benchmark/.gitignore
vendored
Normal file
1
library/libexpat/expat/tests/benchmark/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/benchmark
|
40
library/libexpat/expat/tests/benchmark/Makefile.am
Normal file
40
library/libexpat/expat/tests/benchmark/Makefile.am
Normal file
@ -0,0 +1,40 @@
|
||||
#
|
||||
# __ __ _
|
||||
# ___\ \/ /_ __ __ _| |_
|
||||
# / _ \\ /| '_ \ / _` | __|
|
||||
# | __// \| |_) | (_| | |_
|
||||
# \___/_/\_\ .__/ \__,_|\__|
|
||||
# |_| XML parser
|
||||
#
|
||||
# Copyright (c) 2017 Expat development team
|
||||
# Licensed under the MIT license:
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
# persons to whom the Software is furnished to do so, subject to the
|
||||
# following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/../../lib
|
||||
|
||||
noinst_PROGRAMS = benchmark
|
||||
|
||||
benchmark_SOURCES = benchmark.c
|
||||
|
||||
benchmark_LDADD = ../../lib/libexpat.la
|
||||
|
||||
EXTRA_DIST = \
|
||||
README.txt
|
16
library/libexpat/expat/tests/benchmark/README.txt
Normal file
16
library/libexpat/expat/tests/benchmark/README.txt
Normal file
@ -0,0 +1,16 @@
|
||||
Use this benchmark command line utility as follows:
|
||||
|
||||
benchmark [-n] <file name> <buffer size> <# iterations>
|
||||
|
||||
The command line arguments are:
|
||||
|
||||
-n ... optional; if supplied, namespace processing is turned on
|
||||
<file name> ... name/path of test xml file
|
||||
<buffer size> ... size of processing buffer;
|
||||
the file is parsed in chunks of this size
|
||||
<# iterations> ... how often will the file be parsed
|
||||
|
||||
Returns:
|
||||
|
||||
The time (in seconds) it takes to parse the test file,
|
||||
averaged over the number of iterations.@
|
25
library/libexpat/expat/tests/benchmark/benchmark.sln
Normal file
25
library/libexpat/expat/tests/benchmark/benchmark.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Template|Win32 = Template|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Release|Win32.Build.0 = Release|Win32
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Template|Win32.ActiveCfg = Template|Win32
|
||||
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Template|Win32.Build.0 = Template|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
143
library/libexpat/expat/tests/benchmark/benchmark.vcxproj
Normal file
143
library/libexpat/expat/tests/benchmark/benchmark.vcxproj
Normal file
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Template|Win32">
|
||||
<Configuration>Template</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>.\Debug\</OutDir>
|
||||
<IntDir>.\Debug\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\..\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Release\benchmark.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Release\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Release\benchmark.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x1009</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Release\benchmark.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OutputFile>.\Release\benchmark.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\win32\bin\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libexpat.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\..\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Debug\benchmark.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Debug\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Debug\benchmark.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x1009</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug\benchmark.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OutputFile>.\Debug\benchmark.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\win32\bin\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libexpat.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="benchmark.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
105
library/libexpat/expat/tests/chardata.c
Normal file
105
library/libexpat/expat/tests/chardata.c
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
# include <expat_config.h>
|
||||
#endif
|
||||
#include "minicheck.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "chardata.h"
|
||||
|
||||
|
||||
static int
|
||||
xmlstrlen(const XML_Char *s)
|
||||
{
|
||||
int len = 0;
|
||||
assert(s != NULL);
|
||||
while (s[len] != 0)
|
||||
++len;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CharData_Init(CharData *storage)
|
||||
{
|
||||
assert(storage != NULL);
|
||||
storage->count = -1;
|
||||
}
|
||||
|
||||
void
|
||||
CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len)
|
||||
{
|
||||
int maxchars;
|
||||
|
||||
assert(storage != NULL);
|
||||
assert(s != NULL);
|
||||
maxchars = sizeof(storage->data) / sizeof(storage->data[0]);
|
||||
if (storage->count < 0)
|
||||
storage->count = 0;
|
||||
if (len < 0)
|
||||
len = xmlstrlen(s);
|
||||
if ((len + storage->count) > maxchars) {
|
||||
len = (maxchars - storage->count);
|
||||
}
|
||||
if (len + storage->count < (int)sizeof(storage->data)) {
|
||||
memcpy(storage->data + storage->count, s,
|
||||
len * sizeof(storage->data[0]));
|
||||
storage->count += len;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
CharData_CheckXMLChars(CharData *storage, const XML_Char *expected)
|
||||
{
|
||||
char buffer[1024];
|
||||
int len = xmlstrlen(expected);
|
||||
int count;
|
||||
|
||||
assert(storage != NULL);
|
||||
count = (storage->count < 0) ? 0 : storage->count;
|
||||
if (len != count) {
|
||||
sprintf(buffer, "wrong number of data characters: got %d, expected %d",
|
||||
count, len);
|
||||
fail(buffer);
|
||||
return 0;
|
||||
}
|
||||
if (memcmp(expected, storage->data, len * sizeof(storage->data[0])) != 0) {
|
||||
fail("got bad data bytes");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
63
library/libexpat/expat/tests/chardata.h
Normal file
63
library/libexpat/expat/tests/chardata.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* Interface to some helper routines used to accumulate and check text
|
||||
and attribute content.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XML_CHARDATA_H
|
||||
#define XML_CHARDATA_H 1
|
||||
|
||||
#ifndef XML_VERSION
|
||||
#include "expat.h" /* need XML_Char */
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int count; /* # of chars, < 0 if not set */
|
||||
XML_Char data[2048];
|
||||
} CharData;
|
||||
|
||||
|
||||
void CharData_Init(CharData *storage);
|
||||
|
||||
void CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len);
|
||||
|
||||
int CharData_CheckXMLChars(CharData *storage, const XML_Char *s);
|
||||
|
||||
|
||||
#endif /* XML_CHARDATA_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
198
library/libexpat/expat/tests/memcheck.c
Normal file
198
library/libexpat/expat/tests/memcheck.c
Normal file
@ -0,0 +1,198 @@
|
||||
/* Debug allocators for the Expat test suite
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "memcheck.h"
|
||||
|
||||
|
||||
/* Structures to keep track of what has been allocated. Speed isn't a
|
||||
* big issue for the tests this is required for, so we will use a
|
||||
* doubly-linked list to make deletion easier.
|
||||
*/
|
||||
|
||||
typedef struct allocation_entry {
|
||||
struct allocation_entry * next;
|
||||
struct allocation_entry * prev;
|
||||
void * allocation;
|
||||
size_t num_bytes;
|
||||
} AllocationEntry;
|
||||
|
||||
static AllocationEntry *alloc_head = NULL;
|
||||
static AllocationEntry *alloc_tail = NULL;
|
||||
|
||||
static AllocationEntry *find_allocation(void *ptr);
|
||||
|
||||
|
||||
/* Allocate some memory and keep track of it. */
|
||||
void *
|
||||
tracking_malloc(size_t size)
|
||||
{
|
||||
AllocationEntry *entry = malloc(sizeof(AllocationEntry));
|
||||
|
||||
if (entry == NULL) {
|
||||
printf("Allocator failure\n");
|
||||
return NULL;
|
||||
}
|
||||
entry->num_bytes = size;
|
||||
entry->allocation = malloc(size);
|
||||
if (entry->allocation == NULL) {
|
||||
free(entry);
|
||||
return NULL;
|
||||
}
|
||||
entry->next = NULL;
|
||||
|
||||
/* Add to the list of allocations */
|
||||
if (alloc_head == NULL) {
|
||||
entry->prev = NULL;
|
||||
alloc_head = alloc_tail = entry;
|
||||
} else {
|
||||
entry->prev = alloc_tail;
|
||||
alloc_tail->next = entry;
|
||||
alloc_tail = entry;
|
||||
}
|
||||
|
||||
return entry->allocation;
|
||||
}
|
||||
|
||||
static AllocationEntry *
|
||||
find_allocation(void *ptr)
|
||||
{
|
||||
AllocationEntry *entry;
|
||||
|
||||
for (entry = alloc_head; entry != NULL; entry = entry->next) {
|
||||
if (entry->allocation == ptr) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free some memory and remove the tracking for it */
|
||||
void
|
||||
tracking_free(void *ptr)
|
||||
{
|
||||
AllocationEntry *entry;
|
||||
|
||||
if (ptr == NULL) {
|
||||
/* There won't be an entry for this */
|
||||
return;
|
||||
}
|
||||
|
||||
entry = find_allocation(ptr);
|
||||
if (entry != NULL) {
|
||||
/* This is the relevant allocation. Unlink it */
|
||||
if (entry->prev != NULL)
|
||||
entry->prev->next = entry->next;
|
||||
else
|
||||
alloc_head = entry->next;
|
||||
if (entry->next != NULL)
|
||||
entry->next->prev = entry->prev;
|
||||
else
|
||||
alloc_tail = entry->next;
|
||||
free(entry);
|
||||
} else {
|
||||
printf("Attempting to free unallocated memory at %p\n", ptr);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
/* Reallocate some memory and keep track of it */
|
||||
void *
|
||||
tracking_realloc(void *ptr, size_t size)
|
||||
{
|
||||
AllocationEntry *entry;
|
||||
|
||||
if (ptr == NULL) {
|
||||
/* By definition, this is equivalent to malloc(size) */
|
||||
return tracking_malloc(size);
|
||||
}
|
||||
if (size == 0) {
|
||||
/* By definition, this is equivalent to free(ptr) */
|
||||
tracking_free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find the allocation entry for this memory */
|
||||
entry = find_allocation(ptr);
|
||||
if (entry == NULL) {
|
||||
printf("Attempting to realloc unallocated memory at %p\n", ptr);
|
||||
entry = malloc(sizeof(AllocationEntry));
|
||||
if (entry == NULL) {
|
||||
printf("Reallocator failure\n");
|
||||
return NULL;
|
||||
}
|
||||
entry->allocation = realloc(ptr, size);
|
||||
if (entry->allocation == NULL) {
|
||||
free(entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add to the list of allocations */
|
||||
entry->next = NULL;
|
||||
if (alloc_head == NULL) {
|
||||
entry->prev = NULL;
|
||||
alloc_head = alloc_tail = entry;
|
||||
} else {
|
||||
entry->prev = alloc_tail;
|
||||
alloc_tail->next = entry;
|
||||
alloc_tail = entry;
|
||||
}
|
||||
} else {
|
||||
entry->allocation = realloc(ptr, size);
|
||||
if (entry->allocation == NULL) {
|
||||
/* Realloc semantics say the original is still allocated */
|
||||
entry->allocation = ptr;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
entry->num_bytes = size;
|
||||
return entry->allocation;
|
||||
}
|
||||
|
||||
int
|
||||
tracking_report(void)
|
||||
{
|
||||
AllocationEntry *entry;
|
||||
|
||||
if (alloc_head == NULL)
|
||||
return 1;
|
||||
|
||||
/* Otherwise we have allocations that haven't been freed */
|
||||
for (entry = alloc_head; entry != NULL; entry = entry->next)
|
||||
{
|
||||
printf("Allocated %lu bytes at %p\n",
|
||||
(long unsigned)entry->num_bytes, entry->allocation);
|
||||
}
|
||||
return 0;
|
||||
}
|
57
library/libexpat/expat/tests/memcheck.h
Normal file
57
library/libexpat/expat/tests/memcheck.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* Interface to allocation functions that will track what has or has
|
||||
not been freed.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XML_MEMCHECK_H
|
||||
#define XML_MEMCHECK_H 1
|
||||
|
||||
/* Allocation declarations */
|
||||
|
||||
void *tracking_malloc(size_t size);
|
||||
void tracking_free(void *ptr);
|
||||
void *tracking_realloc(void *ptr, size_t size);
|
||||
|
||||
/* End-of-test check to see if unfreed allocations remain. Returns
|
||||
* TRUE (1) if there is nothing, otherwise prints a report of the
|
||||
* remaining allocations and returns FALSE (0).
|
||||
*/
|
||||
int tracking_report(void);
|
||||
|
||||
#endif /* XML_MEMCHECK_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
242
library/libexpat/expat/tests/minicheck.c
Normal file
242
library/libexpat/expat/tests/minicheck.c
Normal file
@ -0,0 +1,242 @@
|
||||
/* Miniature re-implementation of the "check" library.
|
||||
|
||||
This is intended to support just enough of check to run the Expat
|
||||
tests. This interface is based entirely on the portion of the
|
||||
check library being used.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "internal.h" /* for UNUSED_P only */
|
||||
#include "minicheck.h"
|
||||
|
||||
Suite *
|
||||
suite_create(const char *name)
|
||||
{
|
||||
Suite *suite = (Suite *) calloc(1, sizeof(Suite));
|
||||
if (suite != NULL) {
|
||||
suite->name = name;
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
TCase *
|
||||
tcase_create(const char *name)
|
||||
{
|
||||
TCase *tc = (TCase *) calloc(1, sizeof(TCase));
|
||||
if (tc != NULL) {
|
||||
tc->name = name;
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
void
|
||||
suite_add_tcase(Suite *suite, TCase *tc)
|
||||
{
|
||||
assert(suite != NULL);
|
||||
assert(tc != NULL);
|
||||
assert(tc->next_tcase == NULL);
|
||||
|
||||
tc->next_tcase = suite->tests;
|
||||
suite->tests = tc;
|
||||
}
|
||||
|
||||
void
|
||||
tcase_add_checked_fixture(TCase *tc,
|
||||
tcase_setup_function setup,
|
||||
tcase_teardown_function teardown)
|
||||
{
|
||||
assert(tc != NULL);
|
||||
tc->setup = setup;
|
||||
tc->teardown = teardown;
|
||||
}
|
||||
|
||||
void
|
||||
tcase_add_test(TCase *tc, tcase_test_function test)
|
||||
{
|
||||
assert(tc != NULL);
|
||||
if (tc->allocated == tc->ntests) {
|
||||
int nalloc = tc->allocated + 100;
|
||||
size_t new_size = sizeof(tcase_test_function) * nalloc;
|
||||
tcase_test_function *new_tests = realloc(tc->tests, new_size);
|
||||
assert(new_tests != NULL);
|
||||
tc->tests = new_tests;
|
||||
tc->allocated = nalloc;
|
||||
}
|
||||
tc->tests[tc->ntests] = test;
|
||||
tc->ntests++;
|
||||
}
|
||||
|
||||
static void
|
||||
tcase_free(TCase *tc)
|
||||
{
|
||||
if (! tc) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(tc->tests);
|
||||
free(tc);
|
||||
}
|
||||
|
||||
static void
|
||||
suite_free(Suite *suite)
|
||||
{
|
||||
if (! suite) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (suite->tests != NULL) {
|
||||
TCase *next = suite->tests->next_tcase;
|
||||
tcase_free(suite->tests);
|
||||
suite->tests = next;
|
||||
}
|
||||
free(suite);
|
||||
}
|
||||
|
||||
SRunner *
|
||||
srunner_create(Suite *suite)
|
||||
{
|
||||
SRunner *runner = calloc(1, sizeof(SRunner));
|
||||
if (runner != NULL) {
|
||||
runner->suite = suite;
|
||||
}
|
||||
return runner;
|
||||
}
|
||||
|
||||
static jmp_buf env;
|
||||
|
||||
static char const *_check_current_function = NULL;
|
||||
static int _check_current_lineno = -1;
|
||||
static char const *_check_current_filename = NULL;
|
||||
|
||||
void
|
||||
_check_set_test_info(char const *function, char const *filename, int lineno)
|
||||
{
|
||||
_check_current_function = function;
|
||||
_check_current_lineno = lineno;
|
||||
_check_current_filename = filename;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_failure(SRunner *runner, int verbosity)
|
||||
{
|
||||
runner->nfailures++;
|
||||
if (verbosity >= CK_VERBOSE) {
|
||||
printf("%s:%d: %s\n", _check_current_filename,
|
||||
_check_current_lineno, _check_current_function);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
srunner_run_all(SRunner *runner, int verbosity)
|
||||
{
|
||||
Suite *suite;
|
||||
TCase *tc;
|
||||
assert(runner != NULL);
|
||||
suite = runner->suite;
|
||||
tc = suite->tests;
|
||||
while (tc != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < tc->ntests; ++i) {
|
||||
runner->nchecks++;
|
||||
|
||||
if (tc->setup != NULL) {
|
||||
/* setup */
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
tc->setup();
|
||||
}
|
||||
/* test */
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
(tc->tests[i])();
|
||||
|
||||
/* teardown */
|
||||
if (tc->teardown != NULL) {
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
tc->teardown();
|
||||
}
|
||||
}
|
||||
tc = tc->next_tcase;
|
||||
}
|
||||
if (verbosity) {
|
||||
int passed = runner->nchecks - runner->nfailures;
|
||||
double percentage = ((double) passed) / runner->nchecks;
|
||||
int display = (int) (percentage * 100);
|
||||
printf("%d%%: Checks: %d, Failed: %d\n",
|
||||
display, runner->nchecks, runner->nfailures);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_fail_unless(int UNUSED_P(condition), const char *UNUSED_P(file), int UNUSED_P(line), const char *msg)
|
||||
{
|
||||
/* Always print the error message so it isn't lost. In this case,
|
||||
we have a failure, so there's no reason to be quiet about what
|
||||
it is.
|
||||
*/
|
||||
if (msg != NULL) {
|
||||
const int has_newline = (msg[strlen(msg) - 1] == '\n');
|
||||
fprintf(stderr, "ERROR: %s%s", msg, has_newline ? "" : "\n");
|
||||
}
|
||||
longjmp(env, 1);
|
||||
}
|
||||
|
||||
int
|
||||
srunner_ntests_failed(SRunner *runner)
|
||||
{
|
||||
assert(runner != NULL);
|
||||
return runner->nfailures;
|
||||
}
|
||||
|
||||
void
|
||||
srunner_free(SRunner *runner)
|
||||
{
|
||||
if (! runner) {
|
||||
return;
|
||||
}
|
||||
|
||||
suite_free(runner->suite);
|
||||
free(runner);
|
||||
}
|
119
library/libexpat/expat/tests/minicheck.h
Normal file
119
library/libexpat/expat/tests/minicheck.h
Normal file
@ -0,0 +1,119 @@
|
||||
/* Miniature re-implementation of the "check" library.
|
||||
|
||||
This is intended to support just enough of check to run the Expat
|
||||
tests. This interface is based entirely on the portion of the
|
||||
check library being used.
|
||||
|
||||
This is *source* compatible, but not necessary *link* compatible.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CK_NOFORK 0
|
||||
#define CK_FORK 1
|
||||
|
||||
#define CK_SILENT 0
|
||||
#define CK_NORMAL 1
|
||||
#define CK_VERBOSE 2
|
||||
|
||||
/* Workaround for Microsoft's compiler and Tru64 Unix systems where the
|
||||
C compiler has a working __func__, but the C++ compiler only has a
|
||||
working __FUNCTION__. This could be fixed in configure.in, but it's
|
||||
not worth it right now. */
|
||||
#if defined (_MSC_VER) || (defined(__osf__) && defined(__cplusplus))
|
||||
#define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#define START_TEST(testname) static void testname(void) { \
|
||||
_check_set_test_info(__func__, __FILE__, __LINE__); \
|
||||
{
|
||||
#define END_TEST } }
|
||||
|
||||
#define fail(msg) _fail_unless(0, __FILE__, __LINE__, msg)
|
||||
|
||||
typedef void (*tcase_setup_function)(void);
|
||||
typedef void (*tcase_teardown_function)(void);
|
||||
typedef void (*tcase_test_function)(void);
|
||||
|
||||
typedef struct SRunner SRunner;
|
||||
typedef struct Suite Suite;
|
||||
typedef struct TCase TCase;
|
||||
|
||||
struct SRunner {
|
||||
Suite *suite;
|
||||
int nchecks;
|
||||
int nfailures;
|
||||
};
|
||||
|
||||
struct Suite {
|
||||
const char *name;
|
||||
TCase *tests;
|
||||
};
|
||||
|
||||
struct TCase {
|
||||
const char *name;
|
||||
tcase_setup_function setup;
|
||||
tcase_teardown_function teardown;
|
||||
tcase_test_function *tests;
|
||||
int ntests;
|
||||
int allocated;
|
||||
TCase *next_tcase;
|
||||
};
|
||||
|
||||
|
||||
/* Internal helper. */
|
||||
void _check_set_test_info(char const *function,
|
||||
char const *filename, int lineno);
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for the actual implementation.
|
||||
*/
|
||||
|
||||
void _fail_unless(int condition, const char *file, int line, const char *msg);
|
||||
Suite *suite_create(const char *name);
|
||||
TCase *tcase_create(const char *name);
|
||||
void suite_add_tcase(Suite *suite, TCase *tc);
|
||||
void tcase_add_checked_fixture(TCase *,
|
||||
tcase_setup_function,
|
||||
tcase_teardown_function);
|
||||
void tcase_add_test(TCase *tc, tcase_test_function test);
|
||||
SRunner *srunner_create(Suite *suite);
|
||||
void srunner_run_all(SRunner *runner, int verbosity);
|
||||
int srunner_ntests_failed(SRunner *runner);
|
||||
void srunner_free(SRunner *runner);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
12371
library/libexpat/expat/tests/runtests.c
Normal file
12371
library/libexpat/expat/tests/runtests.c
Normal file
File diff suppressed because it is too large
Load Diff
24
library/libexpat/expat/tests/runtests.sln
Normal file
24
library/libexpat/expat/tests/runtests.sln
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runtests", "runtests.vcxproj", "{63D6D820-B526-4A5F-9605-9B8551FAC591}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Template|Win32 = Template|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Release|Win32.Build.0 = Release|Win32
|
||||
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Template|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
142
library/libexpat/expat/tests/runtests.vcxproj
Normal file
142
library/libexpat/expat/tests/runtests.vcxproj
Normal file
@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{63D6D820-B526-4A5F-9605-9B8551FAC591}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>.\Debug\</OutDir>
|
||||
<IntDir>.\Debug\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Release\runtests.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Release\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Release\runtests.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x1009</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Release\runtests.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OutputFile>.\Release\runtests.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\win32\bin\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libexpatMT.lib;libexpat.exp;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Debug\runtests.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Debug\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<TypeLibraryName>.\Debug\runtests.tlb</TypeLibraryName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x1009</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug\runtests.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OutputFile>.\Debug\runtests.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\win32\bin\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>libexpatMT.lib;libexpat.exp;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="chardata.c" />
|
||||
<ClCompile Include="minicheck.c" />
|
||||
<ClCompile Include="memcheck.c" />
|
||||
<ClCompile Include="runtests.c" />
|
||||
<ClCompile Include="structdata.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="chardata.h" />
|
||||
<ClInclude Include="minicheck.h" />
|
||||
<ClInclude Include="memcheck.h" />
|
||||
<ClInclude Include="structdata.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
48
library/libexpat/expat/tests/runtests.vcxproj.filters
Normal file
48
library/libexpat/expat/tests/runtests.vcxproj.filters
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{a3e83144-e1b8-4d37-853a-793ce2b17b31}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{6a1287d5-359d-4ecb-a1a8-79aec14ad46d}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{75f72e18-16a8-453e-84bc-fe9301b8d5b2}</UniqueIdentifier>
|
||||
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="chardata.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="minicheck.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="memcheck.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="runtests.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="structdata.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="chardata.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="minicheck.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="memcheck.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="structdata.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
36
library/libexpat/expat/tests/runtestspp.cpp
Normal file
36
library/libexpat/expat/tests/runtestspp.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/* C++ compilation harness for the test suite.
|
||||
|
||||
This is used to ensure the Expat headers can be included from C++
|
||||
and have everything work as expected.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtests.c"
|
162
library/libexpat/expat/tests/structdata.c
Normal file
162
library/libexpat/expat/tests/structdata.c
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
# include "expat_config.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "structdata.h"
|
||||
#include "minicheck.h"
|
||||
|
||||
#define STRUCT_EXTENSION_COUNT 8
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
# include <wchar.h>
|
||||
# define XML_FMT_STR "ls"
|
||||
# define xcstrlen(s) wcslen(s)
|
||||
# define xcstrcmp(s, t) wcscmp((s), (t))
|
||||
#else
|
||||
# define XML_FMT_STR "s"
|
||||
# define xcstrlen(s) strlen(s)
|
||||
# define xcstrcmp(s, t) strcmp((s), (t))
|
||||
#endif
|
||||
|
||||
|
||||
static XML_Char *
|
||||
xmlstrdup(const XML_Char *s)
|
||||
{
|
||||
size_t byte_count = (xcstrlen(s) + 1) * sizeof(XML_Char);
|
||||
XML_Char *dup = malloc(byte_count);
|
||||
|
||||
assert(dup != NULL);
|
||||
memcpy(dup, s, byte_count);
|
||||
return dup;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StructData_Init(StructData *storage)
|
||||
{
|
||||
assert(storage != NULL);
|
||||
storage->count = 0;
|
||||
storage->max_count = 0;
|
||||
storage->entries = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
StructData_AddItem(StructData *storage,
|
||||
const XML_Char *s,
|
||||
int data0,
|
||||
int data1,
|
||||
int data2)
|
||||
{
|
||||
StructDataEntry *entry;
|
||||
|
||||
assert(storage != NULL);
|
||||
assert(s != NULL);
|
||||
if (storage->count == storage->max_count) {
|
||||
StructDataEntry *new;
|
||||
|
||||
storage->max_count += STRUCT_EXTENSION_COUNT;
|
||||
new = realloc(storage->entries,
|
||||
storage->max_count * sizeof(StructDataEntry));
|
||||
assert(new != NULL);
|
||||
storage->entries = new;
|
||||
}
|
||||
|
||||
entry = &storage->entries[storage->count];
|
||||
entry->str = xmlstrdup(s);
|
||||
entry->data0 = data0;
|
||||
entry->data1 = data1;
|
||||
entry->data2 = data2;
|
||||
storage->count++;
|
||||
}
|
||||
|
||||
/* 'fail()' aborts the function via a longjmp, so there is no point
|
||||
* in returning a value from this function.
|
||||
*/
|
||||
void
|
||||
StructData_CheckItems(StructData *storage,
|
||||
const StructDataEntry *expected,
|
||||
int count)
|
||||
{
|
||||
char buffer[1024];
|
||||
int i;
|
||||
|
||||
assert(storage != NULL);
|
||||
assert(expected != NULL);
|
||||
if (count != storage->count) {
|
||||
sprintf(buffer, "wrong number of entries: got %d, expected %d",
|
||||
storage->count, count);
|
||||
StructData_Dispose(storage);
|
||||
fail(buffer);
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
const StructDataEntry *got = &storage->entries[i];
|
||||
const StructDataEntry *want = &expected[i];
|
||||
|
||||
if (xcstrcmp(got->str, want->str) != 0) {
|
||||
StructData_Dispose(storage);
|
||||
fail("structure got bad string");
|
||||
}
|
||||
if (got->data0 != want->data0 ||
|
||||
got->data1 != want->data1 ||
|
||||
got->data2 != want->data2) {
|
||||
sprintf(buffer,
|
||||
"struct '%" XML_FMT_STR
|
||||
"' expected (%d,%d,%d), got (%d,%d,%d)",
|
||||
got->str,
|
||||
want->data0, want->data1, want->data2,
|
||||
got->data0, got->data1, got->data2);
|
||||
StructData_Dispose(storage);
|
||||
fail(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
StructData_Dispose(StructData *storage)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(storage != NULL);
|
||||
for (i = 0; i < storage->count; i++)
|
||||
free((void *)storage->entries[i].str);
|
||||
free(storage->entries);
|
||||
}
|
76
library/libexpat/expat/tests/structdata.h
Normal file
76
library/libexpat/expat/tests/structdata.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* Interface to some helper routines used to accumulate and check
|
||||
structured content.
|
||||
__ __ _
|
||||
___\ \/ /_ __ __ _| |_
|
||||
/ _ \\ /| '_ \ / _` | __|
|
||||
| __// \| |_) | (_| | |_
|
||||
\___/_/\_\ .__/ \__,_|\__|
|
||||
|_| XML parser
|
||||
|
||||
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
||||
Copyright (c) 2000-2017 Expat development team
|
||||
Licensed under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XML_STRUCTDATA_H
|
||||
#define XML_STRUCTDATA_H 1
|
||||
|
||||
#include "expat.h"
|
||||
|
||||
typedef struct {
|
||||
const XML_Char *str;
|
||||
int data0;
|
||||
int data1;
|
||||
int data2;
|
||||
} StructDataEntry;
|
||||
|
||||
typedef struct {
|
||||
int count; /* Number of entries used */
|
||||
int max_count; /* Number of StructDataEntry items in `entries` */
|
||||
StructDataEntry *entries;
|
||||
} StructData;
|
||||
|
||||
|
||||
void StructData_Init(StructData *storage);
|
||||
|
||||
void StructData_AddItem(StructData *storage,
|
||||
const XML_Char *s,
|
||||
int data0,
|
||||
int data1,
|
||||
int data2);
|
||||
|
||||
void StructData_CheckItems(StructData *storage,
|
||||
const StructDataEntry *expected,
|
||||
int count);
|
||||
|
||||
void StructData_Dispose(StructData *storage);
|
||||
|
||||
|
||||
#endif /* XML_STRUCTDATA_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
62
library/libexpat/expat/tests/udiffer.py
Executable file
62
library/libexpat/expat/tests/udiffer.py
Executable file
@ -0,0 +1,62 @@
|
||||
#! /usr/bin/env python3
|
||||
# __ __ _
|
||||
# ___\ \/ /_ __ __ _| |_
|
||||
# / _ \\ /| '_ \ / _` | __|
|
||||
# | __// \| |_) | (_| | |_
|
||||
# \___/_/\_\ .__/ \__,_|\__|
|
||||
# |_| XML parser
|
||||
#
|
||||
# Copyright (c) 2017 Expat development team
|
||||
# Licensed under the MIT license:
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
# persons to whom the Software is furnished to do so, subject to the
|
||||
# following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import argparse
|
||||
import difflib
|
||||
import sys
|
||||
|
||||
|
||||
def _read_lines(filename):
|
||||
try:
|
||||
with open(filename) as f:
|
||||
return f.readlines()
|
||||
except UnicodeDecodeError:
|
||||
with open(filename, encoding='utf_16') as f:
|
||||
return f.readlines()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('first', metavar='FILE')
|
||||
parser.add_argument('second', metavar='FILE')
|
||||
config = parser.parse_args()
|
||||
|
||||
first = _read_lines(config.first)
|
||||
second = _read_lines(config.second)
|
||||
|
||||
diffs = list(difflib.unified_diff(first, second, fromfile=config.first,
|
||||
tofile=config.second))
|
||||
if diffs:
|
||||
sys.stdout.writelines(diffs)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
10
library/libexpat/expat/tests/xmltest.log.expected
Normal file
10
library/libexpat/expat/tests/xmltest.log.expected
Normal file
@ -0,0 +1,10 @@
|
||||
Output differs: ibm/valid/P02/ibm02v01.xml
|
||||
ibm49i02.dtd: No such file or directory
|
||||
Expected not well-formed: ibm/not-wf/misc/432gewf.xml
|
||||
Expected not well-formed: xmltest/not-wf/not-sa/005.xml
|
||||
Expected not well-formed: sun/not-wf/uri01.xml
|
||||
Expected not well-formed: oasis/p06fail1.xml
|
||||
Expected not well-formed: oasis/p08fail1.xml
|
||||
Expected not well-formed: oasis/p08fail2.xml
|
||||
Passed: 1801
|
||||
Failed: 8
|
147
library/libexpat/expat/tests/xmltest.sh
Executable file
147
library/libexpat/expat/tests/xmltest.sh
Executable file
@ -0,0 +1,147 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
||||
|
||||
# This script can be used to exercise Expat against the
|
||||
# w3c.org xml test suite, available from
|
||||
# http://www.w3.org/XML/Test/xmlts20020606.zip.
|
||||
|
||||
# To run this script, first set XMLWF below so that xmlwf can be
|
||||
# found, then set the output directory with OUTPUT.
|
||||
|
||||
# The script lists all test cases where Expat shows a discrepancy
|
||||
# from the expected result. Test cases where only the canonical
|
||||
# output differs are prefixed with "Output differs:", and a diff file
|
||||
# is generated in the appropriate subdirectory under $OUTPUT.
|
||||
|
||||
# If there are output files provided, the script will use
|
||||
# output from xmlwf and compare the desired output against it.
|
||||
# However, one has to take into account that the canonical output
|
||||
# produced by xmlwf conforms to an older definition of canonical XML
|
||||
# and does not generate notation declarations.
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
MYDIR="`dirname \"$0\"`"
|
||||
cd "$MYDIR"
|
||||
MYDIR="`pwd`"
|
||||
XMLWF="${1:-`dirname \"$MYDIR\"`/xmlwf/xmlwf}"
|
||||
# XMLWF=/usr/local/bin/xmlwf
|
||||
TS="$MYDIR"
|
||||
# OUTPUT must terminate with the directory separator.
|
||||
OUTPUT="$TS/out/"
|
||||
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||
# Unicode-aware diff utility
|
||||
DIFF="$TS/udiffer.py"
|
||||
|
||||
|
||||
# RunXmlwfNotWF file reldir
|
||||
# reldir includes trailing slash
|
||||
RunXmlwfNotWF() {
|
||||
file="$1"
|
||||
reldir="$2"
|
||||
$XMLWF -p "$file" > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
echo "Expected not well-formed: $reldir$file"
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# RunXmlwfWF file reldir
|
||||
# reldir includes trailing slash
|
||||
RunXmlwfWF() {
|
||||
file="$1"
|
||||
reldir="$2"
|
||||
$XMLWF -p -N -d "$OUTPUT$reldir" "$file" > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
if [ -f "out/$file" ] ; then
|
||||
$DIFF "$OUTPUT$reldir$file" "out/$file" > outfile
|
||||
if [ -s outfile ] ; then
|
||||
cp outfile "$OUTPUT$reldir$file.diff"
|
||||
echo "Output differs: $reldir$file"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "In $reldir: $outdata"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
SUCCESS=0
|
||||
ERROR=0
|
||||
|
||||
UpdateStatus() {
|
||||
if [ "$1" -eq 0 ] ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
}
|
||||
|
||||
##########################
|
||||
# well-formed test cases #
|
||||
##########################
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/valid/P* \
|
||||
ibm/invalid/P* \
|
||||
xmltest/valid/ext-sa \
|
||||
xmltest/valid/not-sa \
|
||||
xmltest/invalid \
|
||||
xmltest/invalid/not-sa \
|
||||
xmltest/valid/sa \
|
||||
sun/valid \
|
||||
sun/invalid ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
mkdir -p "$OUTPUT$xmldir"
|
||||
for xmlfile in $(ls -1 *.xml | sort -d) ; do
|
||||
[[ -f "$xmlfile" ]] || continue
|
||||
RunXmlwfWF "$xmlfile" "$xmldir/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm -f outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
mkdir -p "$OUTPUT"oasis
|
||||
for xmlfile in *pass*.xml ; do
|
||||
RunXmlwfWF "$xmlfile" "oasis/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
|
||||
##############################
|
||||
# not well-formed test cases #
|
||||
##############################
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/not-wf/P* \
|
||||
ibm/not-wf/p28a \
|
||||
ibm/not-wf/misc \
|
||||
xmltest/not-wf/ext-sa \
|
||||
xmltest/not-wf/not-sa \
|
||||
xmltest/not-wf/sa \
|
||||
sun/not-wf ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
for xmlfile in *.xml ; do
|
||||
RunXmlwfNotWF "$xmlfile" "$xmldir/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
for xmlfile in *fail*.xml ; do
|
||||
RunXmlwfNotWF "$xmlfile" "oasis/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
|
||||
echo "Passed: $SUCCESS"
|
||||
echo "Failed: $ERROR"
|
Reference in New Issue
Block a user