~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/core/test_sizeof.in

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
#include "emscripten.h"
 
4
 
 
5
struct A {
 
6
  int x, y;
 
7
};
 
8
 
 
9
int main(int argc, const char *argv[]) {
 
10
  int *a = new int[10];
 
11
  int *b = new int[1];
 
12
  int *c = new int[10];
 
13
  for (int i = 0; i < 10; i++) a[i] = 2;
 
14
  *b = 5;
 
15
  for (int i = 0; i < 10; i++) c[i] = 8;
 
16
  printf("*%d,%d,%d,%d,%d*\n", a[0], a[9], *b, c[0], c[9]);
 
17
  // Should overwrite a, but not touch b!
 
18
  memcpy(a, c, 10 * sizeof(int));
 
19
  printf("*%d,%d,%d,%d,%d*\n", a[0], a[9], *b, c[0], c[9]);
 
20
 
 
21
  // Part 2
 
22
  A as[3] = {{5, 12}, {6, 990}, {7, 2}};
 
23
  memcpy(&as[0], &as[2], sizeof(A));
 
24
 
 
25
  printf("*%d,%d,%d,%d,%d,%d*\n", as[0].x, as[0].y, as[1].x, as[1].y, as[2].x,
 
26
         as[2].y);
 
27
  return 0;
 
28
}