mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-02 10:28:17 -04:00
Merge branch 'master' into doxygen
Conflicts: SDL2pp/AudioDevice.hh
This commit is contained in:
commit
e02beb8692
@ -8,4 +8,4 @@ before_install:
|
|||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq cmake libsdl2-dev libsdl2-image-dev g++-4.8
|
- sudo apt-get install -qq cmake libsdl2-dev libsdl2-image-dev g++-4.8
|
||||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
|
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
|
||||||
script: cmake . -DRUN_GUI_TESTS=OFF -DCMAKE_INSTALL_PREFIX=`pwd`/_prefix -DSDL2PP_WITH_WERROR=YES && make && make test && make install
|
script: cmake . -DSDL2PP_ENABLE_GUI_TEST=OFF -DCMAKE_INSTALL_PREFIX=`pwd`/_prefix -DSDL2PP_WITH_WERROR=YES && make && make test && make install
|
||||||
|
@ -5,6 +5,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
|||||||
|
|
||||||
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
SET(SDL2PP_MAJOR_VERSION 0)
|
||||||
|
SET(SDL2PP_MINOR_VERSION 4)
|
||||||
|
SET(SDL2PP_PATCH_VERSION 0)
|
||||||
|
|
||||||
|
SET(SDL2PP_VERSION "${SDL2PP_MAJOR_VERSION}.${SDL2PP_MINOR_VERSION}.${SDL2PP_PATCH_VERSION}")
|
||||||
|
|
||||||
# there are functions present on wiki, but not yet in stable SDL2 releases;
|
# there are functions present on wiki, but not yet in stable SDL2 releases;
|
||||||
# we hide these under following options
|
# we hide these under following options
|
||||||
OPTION(SDL2PP_WITH_2_0_4 "Enable new functions available only in SDL2 2.0.4+" OFF)
|
OPTION(SDL2PP_WITH_2_0_4 "Enable new functions available only in SDL2 2.0.4+" OFF)
|
||||||
@ -37,6 +43,8 @@ ELSE(MSVC)
|
|||||||
SET(WERROR_FLAG "-Werror")
|
SET(WERROR_FLAG "-Werror")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
|
LIST(REMOVE_DUPLICATES SDL2_ALL_INCLUDE_DIRS)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR})
|
||||||
INCLUDE_DIRECTORIES(${SDL2_ALL_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${SDL2_ALL_INCLUDE_DIRS})
|
||||||
|
|
||||||
@ -94,15 +102,41 @@ IF(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
|||||||
TARGET_LINK_LIBRARIES(SDL2pp ${SDL2_ALL_LIBRARIES})
|
TARGET_LINK_LIBRARIES(SDL2pp ${SDL2_ALL_LIBRARIES})
|
||||||
SET_TARGET_PROPERTIES(SDL2pp PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
SET_TARGET_PROPERTIES(SDL2pp PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
||||||
|
|
||||||
# demos and tests
|
# examples and tests
|
||||||
OPTION(RUN_GUI_TESTS "Run GUI tests (requires X11 display)" ON)
|
OPTION(SDL2PP_WITH_EXAMPLES "Build examples" ON)
|
||||||
ENABLE_TESTING()
|
OPTION(SDL2PP_WITH_TESTS "Build tests" ON)
|
||||||
|
OPTION(SDL2PP_ENABLE_GUI_TEST "Enable GUI test (requires X11 display)" ON)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(demos)
|
IF(SDL2PP_WITH_EXAMPLES)
|
||||||
ADD_SUBDIRECTORY(tests)
|
ADD_SUBDIRECTORY(examples)
|
||||||
|
ENDIF(SDL2PP_WITH_EXAMPLES)
|
||||||
|
|
||||||
|
IF(SDL2PP_WITH_TESTS)
|
||||||
|
ENABLE_TESTING()
|
||||||
|
ADD_SUBDIRECTORY(tests)
|
||||||
|
ENDIF(SDL2PP_WITH_TESTS)
|
||||||
|
|
||||||
|
# pkgconfig
|
||||||
|
SET(PKGCONFIGDIR lib/pkgconfig CACHE STRING "directory where to install pkg-config files")
|
||||||
|
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
SET(PKGCONFIGDIR libdata/pkgconfig)
|
||||||
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
|
||||||
|
SET(SDL2_PKGCONFIG_CFLAGS "")
|
||||||
|
FOREACH(INCDIR IN LISTS SDL2_ALL_INCLUDE_DIRS)
|
||||||
|
SET(SDL2_PKGCONFIG_CFLAGS "${SDL2_PKGCONFIG_CFLAGS} -I${INCDIR}")
|
||||||
|
ENDFOREACH(INCDIR IN SDL2_ALL_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
sdl2pp.pc.in
|
||||||
|
sdl2pp.pc
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
# install
|
||||||
INSTALL(FILES ${LIBRARY_HEADERS} ${PROJECT_BINARY_DIR}/SDL2pp/Config.hh DESTINATION include/SDL2pp)
|
INSTALL(FILES ${LIBRARY_HEADERS} ${PROJECT_BINARY_DIR}/SDL2pp/Config.hh DESTINATION include/SDL2pp)
|
||||||
INSTALL(TARGETS SDL2pp LIBRARY DESTINATION lib)
|
INSTALL(TARGETS SDL2pp LIBRARY DESTINATION lib)
|
||||||
|
INSTALL(FILES ${PROJECT_BINARY_DIR}/sdl2pp.pc DESTINATION ${PKGCONFIGDIR})
|
||||||
ELSE(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
ELSE(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||||
MESSAGE(STATUS "libSDL2pp bundled build")
|
MESSAGE(STATUS "libSDL2pp bundled build")
|
||||||
|
|
||||||
|
25
README.md
25
README.md
@ -83,13 +83,34 @@ Dependencies:
|
|||||||
* SDL_image2 (optional)
|
* SDL_image2 (optional)
|
||||||
|
|
||||||
To build standalone version:
|
To build standalone version:
|
||||||
|
|
||||||
```cmake . && make```
|
```cmake . && make```
|
||||||
|
|
||||||
|
## Installation ##
|
||||||
|
|
||||||
|
To install the library systemwide, run:
|
||||||
|
|
||||||
|
```cmake . && make && make install```
|
||||||
|
|
||||||
|
You can change installation prefix with CMAKE_INSTALL_PREFIX cmake
|
||||||
|
variable:
|
||||||
|
|
||||||
|
```cmake -DCMAKE_INSTALL_PREFIX=/usr/local . && make && make install```
|
||||||
|
|
||||||
|
SDL2pp install pkg-config file, so it can be used with any build
|
||||||
|
system which interacts with pkg-config, including CMake and GNU
|
||||||
|
Autotools.
|
||||||
|
|
||||||
|
SDL2pp is also already available from following package repositories:
|
||||||
|
|
||||||
|
* [Arch Linux AUR](https://aur.archlinux.org/packages/sdl2pp-git/)
|
||||||
|
* [FreeBSD ports](http://www.freshports.org/devel/sdl2pp/)
|
||||||
|
|
||||||
## Bundling ##
|
## Bundling ##
|
||||||
|
|
||||||
The library is easy to integrate into other CMake-using projects
|
The library is easy to integrate into other CMake-using projects
|
||||||
(and as the library has no stable API yet, this way of using it is
|
(and as the library has no stable API yet, this way of using it is
|
||||||
preferred).
|
still recommended).
|
||||||
|
|
||||||
Just place the library into dedicated directory in your project
|
Just place the library into dedicated directory in your project
|
||||||
(for example, lib/SDL2pp) and add
|
(for example, lib/SDL2pp) and add
|
||||||
@ -111,7 +132,7 @@ ADD_EXECUTABLE(mytarget ...)
|
|||||||
TARGET_LINK_LIBRARIES(mytarget ${SDL2PP_LIBRARIES})
|
TARGET_LINK_LIBRARIES(mytarget ${SDL2PP_LIBRARIES})
|
||||||
```
|
```
|
||||||
|
|
||||||
if bundled, libSDL2pp does not build demos and becomes a static
|
if bundled, libSDL2pp does not build examples and becomes a static
|
||||||
library, providing required SDL2 includes/libs in the mentioned
|
library, providing required SDL2 includes/libs in the mentioned
|
||||||
variables.
|
variables.
|
||||||
|
|
||||||
|
@ -135,9 +135,23 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
LockHandle& operator=(LockHandle&& other) noexcept;
|
LockHandle& operator=(LockHandle&& other) noexcept;
|
||||||
|
|
||||||
// Deleted copy constructor and assignment
|
////////////////////////////////////////////////////////////
|
||||||
LockHandle(const LockHandle& other) = delete;
|
/// \brief Copy constructor
|
||||||
LockHandle& operator=(const LockHandle& other) = delete;
|
///
|
||||||
|
/// \param other SDL2pp::AudioDevice::LockHandle to copy data from
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
LockHandle(const LockHandle& other);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Assignment operator
|
||||||
|
///
|
||||||
|
/// \param other SDL2pp::AudioDevice::LockHandle to copy data from
|
||||||
|
///
|
||||||
|
/// \returns Reference to self
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
LockHandle& operator=(const LockHandle& other);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::function<void(Uint8* stream, int len)> AudioCallback;
|
typedef std::function<void(Uint8* stream, int len)> AudioCallback;
|
||||||
|
@ -53,4 +53,21 @@ AudioDevice::LockHandle& AudioDevice::LockHandle::operator=(AudioDevice::LockHan
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioDevice::LockHandle::LockHandle(const AudioDevice::LockHandle& other) : device_(other.device_) {
|
||||||
|
SDL_LockAudioDevice(device_->device_id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioDevice::LockHandle& AudioDevice::LockHandle::operator=(const AudioDevice::LockHandle& other) {
|
||||||
|
if (&other == this)
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
if (device_ != nullptr)
|
||||||
|
SDL_UnlockAudioDevice(device_->device_id_);
|
||||||
|
|
||||||
|
device_ = other.device_;
|
||||||
|
SDL_LockAudioDevice(device_->device_id_);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,12 @@
|
|||||||
#ifndef SDL2PP_CONFIG_HH
|
#ifndef SDL2PP_CONFIG_HH
|
||||||
#define SDL2PP_CONFIG_HH
|
#define SDL2PP_CONFIG_HH
|
||||||
|
|
||||||
|
#define SDL2PP_MAJOR_VERSION @SDL2PP_MAJOR_VERSION@
|
||||||
|
#define SDL2PP_MINOR_VERSION @SDL2PP_MINOR_VERSION@
|
||||||
|
#define SDL2PP_PATCH_VERSION @SDL2PP_PATCH_VERSION@
|
||||||
|
|
||||||
|
#define SDL2PP_VERSION "@SDL2PP_VERSION@"
|
||||||
|
|
||||||
#cmakedefine SDL2PP_WITH_IMAGE
|
#cmakedefine SDL2PP_WITH_IMAGE
|
||||||
#cmakedefine SDL2PP_WITH_2_0_4
|
#cmakedefine SDL2PP_WITH_2_0_4
|
||||||
|
|
||||||
|
@ -137,4 +137,34 @@ bool Rect::Contains(const Point& point) const {
|
|||||||
return !(point.GetX() < GetX() || point.GetY() < GetY() || point.GetX() > GetX2() || point.GetY() > GetY2());
|
return !(point.GetX() < GetX() || point.GetY() < GetY() || point.GetX() > GetX2() || point.GetY() > GetY2());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect Rect::operator+(const Point& offset) const {
|
||||||
|
assert(!IsNull() && !offset.IsNull());
|
||||||
|
|
||||||
|
return Rect(rect_.x + offset.GetX(), rect_.y + offset.GetY(), rect_.w, rect_.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect& Rect::operator+=(const Point& offset) {
|
||||||
|
assert(!IsNull() && !offset.IsNull());
|
||||||
|
|
||||||
|
rect_.x += offset.GetX();
|
||||||
|
rect_.y += offset.GetY();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Rect::operator-(const Point& offset) const {
|
||||||
|
assert(!IsNull() && !offset.IsNull());
|
||||||
|
|
||||||
|
return Rect(rect_.x - offset.GetX(), rect_.y - offset.GetY(), rect_.w, rect_.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect& Rect::operator-=(const Point& offset) {
|
||||||
|
assert(!IsNull() && !offset.IsNull());
|
||||||
|
|
||||||
|
rect_.x -= offset.GetX();
|
||||||
|
rect_.y -= offset.GetY();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,12 @@ public:
|
|||||||
void SetY2(int y2);
|
void SetY2(int y2);
|
||||||
|
|
||||||
bool Contains(const Point& point) const;
|
bool Contains(const Point& point) const;
|
||||||
|
|
||||||
|
Rect operator+(const Point& offset) const;
|
||||||
|
Rect& operator+=(const Point& offset);
|
||||||
|
|
||||||
|
Rect operator-(const Point& offset) const;
|
||||||
|
Rect& operator-=(const Point& offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ void Texture::SetColorMod(Uint8 r, Uint8 g, Uint8 b) {
|
|||||||
throw Exception("SDL_SetTextureColorMod failed");
|
throw Exception("SDL_SetTextureColorMod failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture::LockHandle Texture::Lock(const Rect& rect) {
|
Texture::LockHandle Texture::Lock(const Rect& rect = Rect::Null()) {
|
||||||
return LockHandle(this, rect);
|
return LockHandle(this, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
sdl2pp.pc.in
Normal file
14
sdl2pp.pc.in
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# libSDL2pp pkg-config source file
|
||||||
|
|
||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
libdir=${exec_prefix}/lib
|
||||||
|
includedir=${prefix}/include
|
||||||
|
|
||||||
|
Name: sdl2pp
|
||||||
|
Description: C++11 bindings/wrappers for SDL2.
|
||||||
|
Version: @SDL2PP_VERSION@
|
||||||
|
Requires:
|
||||||
|
Conflicts:
|
||||||
|
Libs: -L${libdir} -lSDL2pp
|
||||||
|
Cflags: -I${includedir}@SDL2_PKGCONFIG_CFLAGS@
|
@ -30,7 +30,7 @@ ENDFOREACH(TEST ${TESTS})
|
|||||||
FOREACH(TEST ${GUI_TESTS})
|
FOREACH(TEST ${GUI_TESTS})
|
||||||
ADD_EXECUTABLE(${TEST} ${TEST}.cc)
|
ADD_EXECUTABLE(${TEST} ${TEST}.cc)
|
||||||
TARGET_LINK_LIBRARIES(${TEST} SDL2pp)
|
TARGET_LINK_LIBRARIES(${TEST} SDL2pp)
|
||||||
IF(RUN_GUI_TESTS)
|
IF(SDL2PP_ENABLE_GUI_TEST)
|
||||||
ADD_TEST(${TEST} ${TEST})
|
ADD_TEST(${TEST} ${TEST})
|
||||||
ENDIF(RUN_GUI_TESTS)
|
ENDIF(SDL2PP_ENABLE_GUI_TEST)
|
||||||
ENDFOREACH(TEST ${TESTS})
|
ENDFOREACH(TEST ${TESTS})
|
||||||
|
@ -173,4 +173,20 @@ BEGIN_TEST()
|
|||||||
EXPECT_TRUE(!r.Contains(Point(15, 20)));
|
EXPECT_TRUE(!r.Contains(Point(15, 20)));
|
||||||
EXPECT_TRUE(!r.Contains(Point(10, 25)));
|
EXPECT_TRUE(!r.Contains(Point(10, 25)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Rect offset
|
||||||
|
Rect r(1, 2, 3, 4);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r + Point(10, 20) == Rect(11, 22, 3, 4));
|
||||||
|
EXPECT_TRUE(r - Point(10, 20) == Rect(-9, -18, 3, 4));
|
||||||
|
|
||||||
|
r += Point(10, 20);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r == Rect(11, 22, 3, 4));
|
||||||
|
|
||||||
|
r -= Point(20, 40);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r == Rect(-9, -18, 3, 4));
|
||||||
|
}
|
||||||
END_TEST()
|
END_TEST()
|
||||||
|
@ -24,19 +24,19 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Seeks
|
// Seeks
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
EXPECT_TRUE(rw.Tell() == 0);
|
EXPECT_TRUE(rw.Tell() == 0);
|
||||||
EXPECT_TRUE(rw.Seek(1, SEEK_SET) == 1);
|
EXPECT_TRUE(rw.Seek(1, RW_SEEK_SET) == 1);
|
||||||
EXPECT_TRUE(rw.Tell() == 1);
|
EXPECT_TRUE(rw.Tell() == 1);
|
||||||
EXPECT_TRUE(rw.Seek(1, SEEK_CUR) == 2);
|
EXPECT_TRUE(rw.Seek(1, RW_SEEK_CUR) == 2);
|
||||||
EXPECT_TRUE(rw.Tell() == 2);
|
EXPECT_TRUE(rw.Tell() == 2);
|
||||||
EXPECT_TRUE(rw.Seek(-1, SEEK_END) == 3);
|
EXPECT_TRUE(rw.Seek(-1, RW_SEEK_END) == 3);
|
||||||
EXPECT_TRUE(rw.Tell() == 3);
|
EXPECT_TRUE(rw.Tell() == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Read via C++
|
// Read via C++
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[4] = {0};
|
char buf[4] = {0};
|
||||||
EXPECT_TRUE(rw.Read(buf, 1, 4) == 4);
|
EXPECT_TRUE(rw.Read(buf, 1, 4) == 4);
|
||||||
@ -48,7 +48,7 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Read via C++
|
// Read via C++
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[4] = {0};
|
char buf[4] = {0};
|
||||||
EXPECT_TRUE(rw.Read(buf, 4, 1) == 1);
|
EXPECT_TRUE(rw.Read(buf, 4, 1) == 1);
|
||||||
@ -60,7 +60,7 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Read via SDL
|
// Read via SDL
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[4] = {0};
|
char buf[4] = {0};
|
||||||
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 1, 4) == 4);
|
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 1, 4) == 4);
|
||||||
@ -72,17 +72,17 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Overread
|
// Overread
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[6] = {0};
|
char buf[6] = {0};
|
||||||
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 3, 2) == 1);
|
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 3, 2) == 1);
|
||||||
rw.Seek(0, SEEK_SET);
|
rw.Seek(0, RW_SEEK_SET);
|
||||||
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 2, 3) == 2);
|
EXPECT_TRUE(SDL_RWread(rw.Get(), buf, 2, 3) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Write
|
// Write
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[2] = {'1', '2'};
|
char buf[2] = {'1', '2'};
|
||||||
EXPECT_TRUE(rw.Write(buf, 1, 2) == 2);
|
EXPECT_TRUE(rw.Write(buf, 1, 2) == 2);
|
||||||
@ -98,7 +98,7 @@ BEGIN_TEST()
|
|||||||
{
|
{
|
||||||
// Write past EOF
|
// Write past EOF
|
||||||
char buf[2] = {'x', 'y'};
|
char buf[2] = {'x', 'y'};
|
||||||
EXPECT_TRUE(rw.Seek(100, SEEK_SET) == 100);
|
EXPECT_TRUE(rw.Seek(100, RW_SEEK_SET) == 100);
|
||||||
|
|
||||||
EXPECT_TRUE(rw.Write(buf, 1, 2) == 2);
|
EXPECT_TRUE(rw.Write(buf, 1, 2) == 2);
|
||||||
EXPECT_TRUE(rw.Tell() == 102);
|
EXPECT_TRUE(rw.Tell() == 102);
|
||||||
@ -123,7 +123,7 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Read via C++
|
// Read via C++
|
||||||
EXPECT_TRUE(rw.Seek(0, SEEK_SET) == 0);
|
EXPECT_TRUE(rw.Seek(0, RW_SEEK_SET) == 0);
|
||||||
|
|
||||||
char buf[4] = {0};
|
char buf[4] = {0};
|
||||||
EXPECT_TRUE(rw.Read(buf, 1, 4) == 4);
|
EXPECT_TRUE(rw.Read(buf, 1, 4) == 4);
|
||||||
@ -152,7 +152,7 @@ BEGIN_TEST()
|
|||||||
EXPECT_TRUE(rw.Write(buf, 1, 4) == 4);
|
EXPECT_TRUE(rw.Write(buf, 1, 4) == 4);
|
||||||
EXPECT_TRUE(rw.Write(buf, 4, 1) == 1);
|
EXPECT_TRUE(rw.Write(buf, 4, 1) == 1);
|
||||||
|
|
||||||
EXPECT_TRUE(rw.Seek(2, SEEK_SET) == 2);
|
EXPECT_TRUE(rw.Seek(2, RW_SEEK_SET) == 2);
|
||||||
EXPECT_TRUE(rw.Write(buf, 2, 2) == 2);
|
EXPECT_TRUE(rw.Write(buf, 2, 2) == 2);
|
||||||
|
|
||||||
EXPECT_TRUE(vec.size() == 8);
|
EXPECT_TRUE(vec.size() == 8);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user