Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5578f009a | |||
| b3830683f6 | |||
| 0060c51c12 | |||
| 23613d16b7 | |||
| 8cd1d56b4a | |||
| 6b8fe820aa | |||
| 2554810306 | |||
| 08029141d4 | |||
| a1123b361d | |||
| f4d2e551b5 | |||
| 1bbe124e3e | |||
| c1b2e29c07 | |||
| a51686c8f0 | |||
| f599b5f425 | |||
| 0063bb8641 |
@@ -34,6 +34,21 @@ jobs:
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract version changelog
|
||||
if: steps.tag.outputs.version
|
||||
id: changelog
|
||||
run: |
|
||||
VERSION="${{ steps.tag.outputs.version }}"
|
||||
CHANGELOG_FILE=$(python3 scripts/get_changelog.py $VERSION)
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "No changelog found for version $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$CHANGELOG_FILE"
|
||||
echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build Artifacts
|
||||
if: steps.tag.outputs.version
|
||||
run: |
|
||||
@@ -46,17 +61,17 @@ jobs:
|
||||
id: create_release
|
||||
run: |
|
||||
VERSION="${{ steps.tag.outputs.version }}"
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"
|
||||
RESPONSE=$(jq -n \
|
||||
--arg tag "v$VERSION" \
|
||||
--arg name "wapp-v$VERSION" \
|
||||
--rawfile body "$CHANGELOG_FILE" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}' \
|
||||
| curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||
-d '{
|
||||
"tag_name": "v'"$VERSION"'",
|
||||
"name": "wapp-v'"$VERSION"'",
|
||||
"body": "Automated release for wapp-v'"$VERSION"'",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}')
|
||||
--data-binary @- \
|
||||
"https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases")
|
||||
|
||||
echo "$RESPONSE"
|
||||
RELEASE_ID=$(echo $RESPONSE | jq -r '.id')
|
||||
@@ -78,4 +93,7 @@ jobs:
|
||||
|
||||
- name: Cleanup
|
||||
if: steps.tag.outputs.version
|
||||
run: rm -rf dist/*
|
||||
run: |
|
||||
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"
|
||||
rm -rf dist/*
|
||||
rm -f "$CHANGELOG_FILE"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.4.0] - 2026-08-30
|
||||
|
||||
### Added
|
||||
|
||||
- `wpStreamHasCount`, `wpStreamPeekWithOffset` and `wpStreamConsumeCount` utilities
|
||||
|
||||
### Fixed
|
||||
|
||||
- Logic for peeking at stream contents
|
||||
|
||||
## [2.3.0] - 2026-08-29
|
||||
|
||||
### Added
|
||||
|
||||
- Compiler detection macros:
|
||||
- `WP_PLATFORM_CLANG` for the clang compiler
|
||||
- `WP_PLATFORM_CLANGPP` for the clang++ compiler
|
||||
- `WP_PLATFORM_CLANG_MAJOR` Major version number for the clang/clang++ compiler
|
||||
- `WP_PLATFORM_CLANG_MINOR` Minor version number for the clang/clang++ compiler
|
||||
- `WP_PLATFORM_CLANG_PATCH` Patch version number for the clang/clang++ compiler
|
||||
- `WP_PLATFORM_GCC` for the gcc compiler
|
||||
- `WP_PLATFORM_GPP` for the g++ compiler
|
||||
- `WP_PLATFORM_GCC_MAJOR` Major version number for the gcc/g++ compiler
|
||||
- `WP_PLATFORM_GCC_MINOR` Minor version number for the gcc/g++ compiler
|
||||
- `WP_PLATFORM_GCC_PATCH` Patch version number for the gcc/g++ compiler
|
||||
- `WP_PLATFORM_MSVC` for Microsoft's Visual C++ compiler
|
||||
- `WP_PLATFORM_MSVC_FULL_VERSION` Full version string for the MSVC compiler
|
||||
- `WP_PLATFORM_MSVC_VERSION` Version string for the MSVC compiler
|
||||
- Generic `WpStream` struct to wrap a stream of data
|
||||
- `WpVoidPtrStream`, `WpC8Stream`, `WpC16Stream`, `WpC32Stream`, `WpU8Stream`, `WpU16Stream`, `WpU32Stream`, `WpU64Stream`, `WpB8Stream`, `WpI8Stream`, `WpI16Stream`, `WpI32Stream`, `WpI64Stream`, `WpF32Stream`, `WpF64Stream`, `WpF128Stream`, `WpUptrStream`, `WpIptrStream` and `WpStr8Stream` aliases for `WpStream` for readability
|
||||
- Utilities for working with data streams:
|
||||
- `wpStreamAtEnd`
|
||||
- `wpStreamHasNext`
|
||||
- `wpStreamPeek`
|
||||
- `wpStreamConsume`
|
||||
@@ -121,13 +121,17 @@ help:
|
||||
@$(ECHO_E) " $(GREEN)make help$(RESET) Print this help message and exit."
|
||||
|
||||
full: LIB_SRC = src/wapp.c
|
||||
full: INCLUDES = common os base prng testing uuid
|
||||
full: INCLUDES = common os base log prng testing uuid
|
||||
full: install
|
||||
|
||||
base: LIB_SRC = src/base/wapp_base.c
|
||||
base: INCLUDES = common base
|
||||
base: install
|
||||
|
||||
log: LIB_SRC = src/log/wapp_log.c
|
||||
log: INCLUDES = common os base log
|
||||
log: install
|
||||
|
||||
os: LIB_SRC = src/os/wapp_os.c
|
||||
os: INCLUDES = common os base
|
||||
os: install
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
import re
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
VERSION_HEADER = re.compile(r"\[\d+.\d+.\d+\]")
|
||||
SCRIPT_DIR = Path(__file__).absolute().parent.parent
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("version")
|
||||
args = parser.parse_args()
|
||||
|
||||
changelog = get_changelog(args.version)
|
||||
outfilename = save_changelog(args.version, changelog)
|
||||
|
||||
print(outfilename)
|
||||
|
||||
|
||||
def get_changelog(version: str) -> list[str]:
|
||||
changelog = SCRIPT_DIR / "CHANGELOG.md"
|
||||
|
||||
with changelog.open("r") as infile:
|
||||
lines = infile.readlines()
|
||||
|
||||
start = -1
|
||||
end = -1
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
if start == -1:
|
||||
match = re.search(version, line)
|
||||
if match is None:
|
||||
continue
|
||||
start = i
|
||||
else:
|
||||
match = VERSION_HEADER.search(line)
|
||||
if match is not None:
|
||||
end = i
|
||||
break
|
||||
|
||||
if start == -1:
|
||||
exit(1)
|
||||
|
||||
return lines[start:end] if end > -1 else lines[start:]
|
||||
|
||||
|
||||
def save_changelog(version: str, lines: list[str]) -> str:
|
||||
version_changelog = SCRIPT_DIR / f"wapp-changelog-{version}.md"
|
||||
with version_changelog.open("w") as outfile:
|
||||
outfile.writelines(lines)
|
||||
return str(version_changelog)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#include "stream.h"
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/assert/assert.h"
|
||||
|
||||
void _streamValidate(const WpStream *stream, u64 item_size);
|
||||
|
||||
b8 wpStreamAtEnd(const WpStream *stream) {
|
||||
return stream->position >= stream->count;
|
||||
}
|
||||
|
||||
b8 _streamHasCount(const WpStream *stream, u64 count) {
|
||||
return stream->position + count <= stream->count;
|
||||
}
|
||||
|
||||
void *_streamPeekWithOffset(const WpStream *stream, u64 offset, u64 item_size) {
|
||||
_streamValidate(stream, item_size);
|
||||
|
||||
if (_streamHasCount(stream, offset + 1)) {
|
||||
u64 index = (stream->position + offset) * stream->item_size;
|
||||
return (void *)(&((u8 *)(stream->data))[index]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *_streamConsumeCount(WpStream *stream, u64 count, u64 item_size) {
|
||||
_streamValidate(stream, item_size);
|
||||
|
||||
if (_streamHasCount(stream, count)) {
|
||||
u64 index = stream->position * stream->item_size;
|
||||
stream->position += count;
|
||||
return (void *)(&((u8 *)(stream->data))[index]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _streamValidate(const WpStream *stream, u64 item_size) {
|
||||
wpDebugAssert(stream != NULL, "`stream` should not be NULL");
|
||||
wpRuntimeAssert(stream->item_size == item_size, "Invalid item type provided");
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef STREAM_H
|
||||
#define STREAM_H
|
||||
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct {
|
||||
void *data;
|
||||
u64 count;
|
||||
u64 position;
|
||||
u64 item_size;
|
||||
} WpStream;
|
||||
|
||||
// NOTE (Abdelrahman): WpStream typedefs for readability
|
||||
typedef WpStream WpVoidPtrStream;
|
||||
typedef WpStream WpC8Stream;
|
||||
typedef WpStream WpC16Stream;
|
||||
typedef WpStream WpC32Stream;
|
||||
typedef WpStream WpU8Stream;
|
||||
typedef WpStream WpU16Stream;
|
||||
typedef WpStream WpU32Stream;
|
||||
typedef WpStream WpU64Stream;
|
||||
typedef WpStream WpB8Stream;
|
||||
typedef WpStream WpI8Stream;
|
||||
typedef WpStream WpI16Stream;
|
||||
typedef WpStream WpI32Stream;
|
||||
typedef WpStream WpI64Stream;
|
||||
typedef WpStream WpF32Stream;
|
||||
typedef WpStream WpF64Stream;
|
||||
typedef WpStream WpF128Stream;
|
||||
typedef WpStream WpUptrStream;
|
||||
typedef WpStream WpIptrStream;
|
||||
typedef WpStream WpStr8Stream;
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
#define wpStream(TYPE, DATA, SIZE) ([&]() { \
|
||||
return WpStream{ \
|
||||
DATA, \
|
||||
SIZE / sizeof(TYPE), \
|
||||
0, \
|
||||
sizeof(TYPE) \
|
||||
}; \
|
||||
}())
|
||||
#else
|
||||
#define wpStream(TYPE, DATA, SIZE) ( \
|
||||
(WpStream){ \
|
||||
.data = DATA, \
|
||||
.count = SIZE / sizeof(TYPE), \
|
||||
.position = 0, \
|
||||
.item_size = sizeof(TYPE) \
|
||||
} \
|
||||
)
|
||||
#endif
|
||||
|
||||
#define wpStreamHasNext(STREAM) _streamHasCount(STREAM, 1)
|
||||
#define wpStreamHasCount(STREAM, COUNT) _streamHasCount(STREAM, COUNT)
|
||||
#define wpStreamPeek(TYPE, STREAM) ((TYPE *)_streamPeekWithOffset(STREAM, 0, sizeof(TYPE)))
|
||||
#define wpStreamPeekWithOffset(TYPE, STREAM, OFFSET) \
|
||||
((TYPE *)_streamPeekWithOffset(STREAM, OFFSET, sizeof(TYPE)))
|
||||
#define wpStreamConsume(TYPE, STREAM) ((TYPE *)_streamConsumeCount(STREAM, 1, sizeof(TYPE)))
|
||||
#define wpStreamConsumeCount(TYPE, STREAM, COUNT) \
|
||||
((TYPE *)_streamConsumeCount(STREAM, COUNT, sizeof(TYPE)))
|
||||
|
||||
b8 wpStreamAtEnd(const WpStream *stream);
|
||||
|
||||
b8 _streamHasCount(const WpStream *stream, u64 count);
|
||||
void *_streamPeekWithOffset(const WpStream *stream, u64 offset, u64 item_size);
|
||||
void *_streamConsumeCount(WpStream *stream, u64 count, u64 item_size);
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !STREAM_H
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "array/array.c"
|
||||
#include "dbl_list/dbl_list.c"
|
||||
#include "queue/queue.c"
|
||||
#include "stream/stream.c"
|
||||
#include "mem/allocator/mem_allocator.c"
|
||||
#include "mem/utils/mem_utils.c"
|
||||
#include "strings/str8/str8.c"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "array/array.h"
|
||||
#include "dbl_list/dbl_list.h"
|
||||
#include "queue/queue.h"
|
||||
#include "stream/stream.h"
|
||||
#include "mem/allocator/mem_allocator.h"
|
||||
#include "mem/utils/mem_utils.h"
|
||||
#include "strings/str8/str8.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
// Operating system
|
||||
#if defined(__ANDROID__)
|
||||
#define WP_PLATFORM_ANDROID
|
||||
#define WP_PLATFORM_POSIX
|
||||
@@ -60,6 +61,39 @@
|
||||
#error "Unrecognised platform"
|
||||
#endif
|
||||
|
||||
// Compiler
|
||||
#if defined(__clang__)
|
||||
#define WP_PLATFORM_CLANG
|
||||
|
||||
#if defined(__GNUG__)
|
||||
#define WP_PLATFORM_CLANGPP
|
||||
#endif
|
||||
|
||||
#define WP_PLATFORM_CLANG_MAJOR __clang_major__
|
||||
#define WP_PLATFORM_CLANG_MINOR __clang_minor__
|
||||
#define WP_PLATFORM_CLANG_PATCH __clang_patchlevel__
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
#define WP_PLATFORM_GCC
|
||||
|
||||
#if defined(__GNUG__)
|
||||
#define WP_PLATFORM_GPP
|
||||
#endif
|
||||
|
||||
#define WP_PLATFORM_GCC_MAJOR __GNUC__
|
||||
#define WP_PLATFORM_GCC_MINOR __GNUC_MINOR__
|
||||
|
||||
#if defined(__GNUC_PATCHLEVEL__)
|
||||
#define WP_PLATFORM_GCC_PATCH __GNUC_PATCHLEVEL__
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#define WP_PLATFORM_MSVC
|
||||
#define WP_PLATFORM_MSVC_FULL_VERSION _MSC_FULL_VER
|
||||
#define WP_PLATFORM_MSVC_VERSION _MSC_VER
|
||||
#else
|
||||
#error "Unrecognised compiler"
|
||||
#endif
|
||||
|
||||
// Language
|
||||
#ifdef __cplusplus
|
||||
#define WP_PLATFORM_CPP
|
||||
#define WP_PLATFORM_CPP_VERSION __cplusplus
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#include "../os/file/file.h"
|
||||
#include "../base/strings/str8/str8.h"
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef enum {
|
||||
WP_LOG_LEVEL_FATAL,
|
||||
WP_LOG_LEVEL_CRITICAL,
|
||||
@@ -31,4 +35,8 @@ void wpLogError(const WpLogger *logger, WpStr8 msg);
|
||||
void wpLogCritical(const WpLogger *logger, WpStr8 msg);
|
||||
void wpLogFatal(const WpLogger *logger, WpStr8 msg);
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
#endif // !LOG_H
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#include "test_stream.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define COUNT 3
|
||||
|
||||
WpTestFuncResult test_stream_at_end(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
for (u32 i = 0; i < COUNT; ++i) {
|
||||
wpStreamConsume(c8, &stream);
|
||||
result = result && (i == 2 ? wpStreamAtEnd(&stream) : !wpStreamAtEnd(&stream));
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_peek(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = NULL;
|
||||
for (u32 i = 0; i <= COUNT; ++i) {
|
||||
c = wpStreamPeek(c8, &stream);
|
||||
wpStreamConsume(c8, &stream);
|
||||
result = result && (i == 3 ? c == NULL : c != NULL);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_peek_with_offset(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
u64 offset = 2;
|
||||
c8 *c = wpStreamPeekWithOffset(c8, &stream, offset);
|
||||
result = result && *c == characters[offset];
|
||||
|
||||
c = wpStreamPeekWithOffset(c8, &stream, 5);
|
||||
result = result && c == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_consume(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = NULL;
|
||||
for (u32 i = 0; i <= COUNT; ++i) {
|
||||
c = wpStreamConsume(c8, &stream);
|
||||
result = result && (i == COUNT ? c == NULL : c != NULL);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_consume_count(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = wpStreamConsumeCount(c8, &stream, COUNT);
|
||||
result = result && c != NULL && wpStreamAtEnd(&stream);
|
||||
|
||||
c = wpStreamConsumeCount(c8, &stream, COUNT);
|
||||
result = result && c == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#include "test_stream.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define COUNT 3
|
||||
|
||||
WpTestFuncResult test_stream_at_end(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
for (u32 i = 0; i < COUNT; ++i) {
|
||||
wpStreamConsume(c8, &stream);
|
||||
result = result && (i == 2 ? wpStreamAtEnd(&stream) : !wpStreamAtEnd(&stream));
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_peek(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = NULL;
|
||||
for (u32 i = 0; i <= COUNT; ++i) {
|
||||
c = wpStreamPeek(c8, &stream);
|
||||
wpStreamConsume(c8, &stream);
|
||||
result = result && (i == 3 ? c == NULL : c != NULL);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_peek_with_offset(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
u64 offset = 2;
|
||||
c8 *c = wpStreamPeekWithOffset(c8, &stream, offset);
|
||||
result = result && *c == characters[offset];
|
||||
|
||||
c = wpStreamPeekWithOffset(c8, &stream, 5);
|
||||
result = result && c == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_consume(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = NULL;
|
||||
for (u32 i = 0; i <= COUNT; ++i) {
|
||||
c = wpStreamConsume(c8, &stream);
|
||||
result = result && (i == COUNT ? c == NULL : c != NULL);
|
||||
}
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
WpTestFuncResult test_stream_consume_count(void) {
|
||||
b8 result = true;
|
||||
|
||||
c8 characters[COUNT] = {'a', 'b', 'c'};
|
||||
WpC8Stream stream = wpStream(c8, characters, COUNT);
|
||||
|
||||
c8 *c = wpStreamConsumeCount(c8, &stream, COUNT);
|
||||
result = result && c != NULL && wpStreamAtEnd(&stream);
|
||||
|
||||
c = wpStreamConsumeCount(c8, &stream, COUNT);
|
||||
result = result && c == NULL;
|
||||
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef TEST_STREAM_H
|
||||
#define TEST_STREAM_H
|
||||
|
||||
#include "wapp.h"
|
||||
|
||||
WpTestFuncResult test_stream_at_end(void);
|
||||
WpTestFuncResult test_stream_peek(void);
|
||||
WpTestFuncResult test_stream_peek_with_offset(void);
|
||||
WpTestFuncResult test_stream_consume(void);
|
||||
WpTestFuncResult test_stream_consume_count(void);
|
||||
|
||||
#endif // !TEST_STREAM_H
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "test_str8_array.h"
|
||||
#include "test_i32_array.h"
|
||||
#include "test_queue.h"
|
||||
#include "test_stream.h"
|
||||
#include "test_cpath.h"
|
||||
#include "test_file.h"
|
||||
#include "test_shell_commander.h"
|
||||
@@ -47,6 +48,11 @@ int main(void) {
|
||||
test_queue_push,
|
||||
test_queue_push_alloc,
|
||||
test_queue_pop,
|
||||
test_stream_at_end,
|
||||
test_stream_peek,
|
||||
test_stream_peek_with_offset,
|
||||
test_stream_consume,
|
||||
test_stream_consume_count,
|
||||
test_str8_lit,
|
||||
test_str8_lit_ro,
|
||||
test_str8_buf,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "test_str8_array.h"
|
||||
#include "test_i32_array.h"
|
||||
#include "test_queue.h"
|
||||
#include "test_stream.h"
|
||||
#include "test_cpath.h"
|
||||
#include "test_file.h"
|
||||
#include "test_shell_commander.h"
|
||||
@@ -47,6 +48,11 @@ int main(void) {
|
||||
test_queue_push,
|
||||
test_queue_push_alloc,
|
||||
test_queue_pop,
|
||||
test_stream_at_end,
|
||||
test_stream_peek,
|
||||
test_stream_peek_with_offset,
|
||||
test_stream_consume,
|
||||
test_stream_consume_count,
|
||||
test_str8_lit,
|
||||
test_str8_lit_ro,
|
||||
test_str8_buf,
|
||||
|
||||
Reference in New Issue
Block a user