Skip to content

Commit

Permalink
Apply some basic formatting rules to test files
Browse files Browse the repository at this point in the history
I mostly did with with some grepping and replacing, and stopped when
I got board.  We probably should just auto-format the whole thing
but I tried that was was overwhelmed by the scale the changes it
made.
  • Loading branch information
sbc100 committed Nov 20, 2023
1 parent c017fc2 commit 31ac18c
Show file tree
Hide file tree
Showing 110 changed files with 950 additions and 1,156 deletions.
25 changes: 12 additions & 13 deletions test/alloc_3gb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#include <stdint.h>
#include <assert.h>

int main()
{
uint8_t *ptr1 = (uint8_t *)malloc(1024*1024);
assert(ptr1);
uint8_t *ptr2 = (uint8_t *)malloc(3u*1024*1024*1024);
assert(ptr2);
uint8_t *ptr3 = (uint8_t *)malloc(1024*1024);
assert(ptr3);
free(ptr1);
free(ptr3);
free(ptr2);
printf("OK\n");
return 0;
int main() {
uint8_t *ptr1 = (uint8_t *)malloc(1024*1024);
assert(ptr1);
uint8_t *ptr2 = (uint8_t *)malloc(3u*1024*1024*1024);
assert(ptr2);
uint8_t *ptr3 = (uint8_t *)malloc(1024*1024);
assert(ptr3);
free(ptr1);
free(ptr3);
free(ptr2);
printf("OK\n");
return 0;
}
2 changes: 0 additions & 2 deletions test/browser/test_sdl2_canvas_blank.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <stdio.h>
#include <SDL2/SDL.h>


int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window;
Expand All @@ -25,4 +24,3 @@ int main() {

return 0;
}

1 change: 0 additions & 1 deletion test/browser/test_sdl2_canvas_palette.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ int main() {

return 0;
}

1 change: 0 additions & 1 deletion test/browser/test_sdl2_canvas_palette_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@ int main(int argc, char** argv) {

return 0;
}

1 change: 0 additions & 1 deletion test/browser/test_sdl2_canvas_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ int main(int argc, char **argv) {
EM_ASM(window.close());
return 0;
}

28 changes: 12 additions & 16 deletions test/browser/webgl_array_of_structs_uniform.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include <GLES2/gl2.h>
#include <GLES3/gl3.h>

GLuint compile_shader(GLenum shaderType, const char *src)
{
GLuint compile_shader(GLenum shaderType, const char *src) {
GLuint shader = glCreateShader(shaderType);
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
Expand All @@ -32,22 +31,20 @@ GLuint compile_shader(GLenum shaderType, const char *src)
return 0;
}

return shader;
return shader;
}

GLuint create_program(GLuint vertexShader, GLuint fragmentShader)
{
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
GLuint create_program(GLuint vertexShader, GLuint fragmentShader) {
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
}

int main()
{
int main() {
EmscriptenWebGLContextAttributes attr;
emscripten_webgl_init_context_attributes(&attr);
attr.majorVersion = 2;
Expand Down Expand Up @@ -80,8 +77,7 @@ int main()
GLuint program = create_program(vs, fs);
glUseProgram(program);

struct P
{
struct P {
float x, y;
int idx;
};
Expand Down
6 changes: 2 additions & 4 deletions test/browser/webgl_color_buffer_readpixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context;

int main()
{
int main() {
EmscriptenWebGLContextAttributes attrs;
emscripten_webgl_init_context_attributes(&attrs);
attrs.enableExtensionsByDefault = true;
Expand Down Expand Up @@ -58,8 +57,7 @@ int main()
printf("GL_IMPLEMENTATION_COLOR_READ_FORMAT for FBO with float renderbuffer: 0x%x\n", format);

// Try glReadPixels() in that format.
if (format == GL_RGBA && type == GL_UNSIGNED_BYTE)
{
if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
printf("Oops, WebGL implementation returns an implementation defined color type(==GL_UNSIGNED_BYTE) & format(==GL_RGBA) that should "
"not be possible to be used to sample WebGL floating point color renderbuffer according to WEBGL_color_buffer_float.\n");
}
Expand Down
29 changes: 13 additions & 16 deletions test/browser/webgl_create_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@
#include <emscripten/html5.h>

std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}

std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}

GLint GetInt(GLenum param)
{
GLint GetInt(GLenum param) {
GLint value;
glGetIntegerv(param, &value);
return value;
Expand All @@ -47,8 +46,7 @@ void final(void*) {

EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context;

void loop()
{
void loop() {
EMSCRIPTEN_RESULT res;
if (!context) {
// new rendering frame started without a context
Expand Down Expand Up @@ -76,8 +74,7 @@ void loop()
}
}

int main()
{
int main() {
bool first = true;
EmscriptenWebGLContextAttributes attrs;
int depth = 0;
Expand Down Expand Up @@ -146,7 +143,7 @@ int main()
printf("RGBA: %d%d%d%d, Depth: %d, Stencil: %d, Samples: %d\n",
GetInt(GL_RED_BITS), GetInt(GL_GREEN_BITS), GetInt(GL_BLUE_BITS), GetInt(GL_ALPHA_BITS),
numDepthBits, numStencilBits, numSamples);

if (!depth && stencil && numDepthBits && numStencilBits && EM_ASM_INT(navigator.userAgent.toLowerCase().indexOf('firefox')) > -1)
{
numDepthBits = 0;
Expand Down
3 changes: 1 addition & 2 deletions test/browser/webgl_create_context2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>

int main()
{
int main() {
EmscriptenWebGLContextAttributes attrs;
emscripten_webgl_init_context_attributes(&attrs);
// Test that creating a context with #canvas target when -sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0
Expand Down
15 changes: 5 additions & 10 deletions test/browser/webgl_destroy_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,28 @@
#include <emscripten.h>
#include <emscripten/html5.h>

void report_result(int result)
{
void report_result(int result) {
printf("Test finished with result %d\n", result);
emscripten_force_exit(result);
}

void finish(void*)
{
void finish(void*) {
report_result(0);
}

EM_BOOL context_lost(int eventType, const void *reserved, void *userData)
{
EM_BOOL context_lost(int eventType, const void *reserved, void *userData) {
printf("C code received a signal for WebGL context lost! This should not happen!\n");
report_result(1);
return 0;
}

EM_BOOL context_restored(int eventType, const void *reserved, void *userData)
{
EM_BOOL context_restored(int eventType, const void *reserved, void *userData) {
printf("C code received a signal for WebGL context restored! This should not happen!\n");
report_result(1);
return 0;
}

int main()
{
int main() {
EmscriptenWebGLContextAttributes attrs;
emscripten_webgl_init_context_attributes(&attrs);
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#canvas", &attrs);
Expand Down
28 changes: 12 additions & 16 deletions test/browser/webgl_draw_base_vertex_base_instance_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

#include <GLES3/gl3.h>

GLuint compile_shader(GLenum shaderType, const char *src)
{
GLuint compile_shader(GLenum shaderType, const char *src) {
GLuint shader = glCreateShader(shaderType);
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
Expand All @@ -34,26 +33,24 @@ GLuint compile_shader(GLenum shaderType, const char *src)
return 0;
}

return shader;
return shader;
}

GLuint create_program(GLuint vertexShader, GLuint fragmentShader)
{
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
GLuint create_program(GLuint vertexShader, GLuint fragmentShader) {
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
}

#ifndef WEBGL_CONTEXT_VERSION
#define WEBGL_CONTEXT_VERSION 2
#endif

int main()
{
int main() {
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx;
EMSCRIPTEN_RESULT res;
EmscriptenWebGLContextAttributes attrs;
Expand All @@ -67,7 +64,7 @@ int main()
#ifdef EXPLICIT_SWAP
attrs.explicitSwapControl = 1;
#endif

GLboolean extAvailable = emscripten_webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(ctx);
extAvailable &= emscripten_webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(ctx);

Expand Down Expand Up @@ -186,5 +183,4 @@ int main()
#ifdef EXPLICIT_SWAP
emscripten_webgl_commit_frame();
#endif

}
22 changes: 10 additions & 12 deletions test/browser/webgl_draw_triangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <emscripten/html5.h>
#include <GLES2/gl2.h>

GLuint compile_shader(GLenum shaderType, const char *src)
{
GLuint compile_shader(GLenum shaderType, const char *src) {
GLuint shader = glCreateShader(shaderType);
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
Expand All @@ -30,22 +29,21 @@ GLuint compile_shader(GLenum shaderType, const char *src)
return 0;
}

return shader;
return shader;
}

GLuint create_program(GLuint vertexShader, GLuint fragmentShader)
{
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
}

int main()
{
int main() {
EmscriptenWebGLContextAttributes attr;
emscripten_webgl_init_context_attributes(&attr);
#ifdef EXPLICIT_SWAP
Expand Down
25 changes: 11 additions & 14 deletions test/browser/webgl_draw_triangle_with_uniform_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <emscripten/html5.h>
#include <GLES2/gl2.h>

GLuint compile_shader(GLenum shaderType, const char *src)
{
GLuint compile_shader(GLenum shaderType, const char *src) {
GLuint shader = glCreateShader(shaderType);
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);
Expand All @@ -30,22 +29,20 @@ GLuint compile_shader(GLenum shaderType, const char *src)
return 0;
}

return shader;
return shader;
}

GLuint create_program(GLuint vertexShader, GLuint fragmentShader)
{
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
GLuint create_program(GLuint vertexShader, GLuint fragmentShader) {
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glBindAttribLocation(program, 0, "apos");
glBindAttribLocation(program, 1, "acolor");
glLinkProgram(program);
return program;
}

int main()
{
int main() {
EmscriptenWebGLContextAttributes attr;
emscripten_webgl_init_context_attributes(&attr);
#ifdef EXPLICIT_SWAP
Expand Down
3 changes: 1 addition & 2 deletions test/browser/webgl_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include <assert.h>
#include <GLES2/gl2.h>

int main()
{
int main() {
EmscriptenWebGLContextAttributes attr;
emscripten_webgl_init_context_attributes(&attr);
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr);
Expand Down
Loading

0 comments on commit 31ac18c

Please sign in to comment.